@kubuild/renderer 0.1.0 → 0.3.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.
- package/README.md +105 -0
- package/dist/action-dispatcher.d.ts +42 -0
- package/dist/action-dispatcher.d.ts.map +1 -0
- package/dist/action-runners/api-request.d.ts +77 -0
- package/dist/action-runners/api-request.d.ts.map +1 -0
- package/dist/action-runners/index.d.ts +24 -0
- package/dist/action-runners/index.d.ts.map +1 -0
- package/dist/action-runners/modal-manager.d.ts +73 -0
- package/dist/action-runners/modal-manager.d.ts.map +1 -0
- package/dist/action-runners/navigation-utils.d.ts +49 -0
- package/dist/action-runners/navigation-utils.d.ts.map +1 -0
- package/dist/action-runners/toast-container.d.ts +20 -0
- package/dist/action-runners/toast-container.d.ts.map +1 -0
- package/dist/action-runners/toast-manager.d.ts +74 -0
- package/dist/action-runners/toast-manager.d.ts.map +1 -0
- package/dist/action-runners/ui-feedback.d.ts +37 -0
- package/dist/action-runners/ui-feedback.d.ts.map +1 -0
- package/dist/artboard-portal-host.d.ts +67 -0
- package/dist/artboard-portal-host.d.ts.map +1 -0
- package/dist/error-boundary.d.ts +2 -0
- package/dist/error-boundary.d.ts.map +1 -1
- package/dist/form-context.d.ts +114 -0
- package/dist/form-context.d.ts.map +1 -0
- package/dist/index.cjs +99 -2690
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +99 -2627
- package/dist/index.js.map +1 -1
- package/dist/nodes/editable-text.d.ts +15 -0
- package/dist/nodes/editable-text.d.ts.map +1 -0
- package/dist/nodes/form-nodes.d.ts +186 -0
- package/dist/nodes/form-nodes.d.ts.map +1 -0
- package/dist/nodes/html-embed.d.ts +15 -0
- package/dist/nodes/html-embed.d.ts.map +1 -0
- package/dist/nodes/index.d.ts +5 -0
- package/dist/nodes/index.d.ts.map +1 -0
- package/dist/nodes/media-utils.d.ts +17 -0
- package/dist/nodes/media-utils.d.ts.map +1 -0
- package/dist/preview-adapter.d.ts +9 -2
- package/dist/preview-adapter.d.ts.map +1 -1
- package/dist/render-context.d.ts +10 -1
- package/dist/render-context.d.ts.map +1 -1
- package/dist/renderer.d.ts +4 -24
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderers/index.d.ts +3 -0
- package/dist/renderers/index.d.ts.map +1 -0
- package/dist/renderers/interactive-renderers.d.ts +7 -0
- package/dist/renderers/interactive-renderers.d.ts.map +1 -0
- package/dist/renderers/render-node-content.d.ts +67 -0
- package/dist/renderers/render-node-content.d.ts.map +1 -0
- package/dist/styles.d.ts +11 -0
- package/dist/styles.d.ts.map +1 -1
- package/package.json +6 -5
- package/dist/index.mjs +0 -44754
- package/dist/index.mjs.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @kubuild/renderer
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@kubuild/renderer)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
|
|
7
|
+
Pure recursive React renderer for **KUBUILD** page documents with Action Dispatcher, built-in action runners (API requests, modals, toasts, navigation), form runtime context, and CSS style compiler.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📦 Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Using pnpm (recommended)
|
|
15
|
+
pnpm add @kubuild/renderer @kubuild/components @kubuild/core @kubuild/schema react react-dom
|
|
16
|
+
|
|
17
|
+
# Using npm
|
|
18
|
+
npm install @kubuild/renderer @kubuild/components @kubuild/core @kubuild/schema react react-dom
|
|
19
|
+
|
|
20
|
+
# Using yarn
|
|
21
|
+
yarn add @kubuild/renderer @kubuild/components @kubuild/core @kubuild/schema react react-dom
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## ✨ Features
|
|
27
|
+
|
|
28
|
+
- **Pure Recursive React Renderer**: High-performance `<Renderer />` component that walks the document node tree recursively and renders React elements.
|
|
29
|
+
- **Action Dispatcher & Built-in Action Runners**:
|
|
30
|
+
- `apiRequest`: Performs HTTP requests with URL parameters, headers, method, body interpolation, and success/error branching.
|
|
31
|
+
- `showToast`: Renders toast notifications (success, error, warning, info) via `ToastContainer`.
|
|
32
|
+
- `openModal` / `closeModal`: Triggers modal dialogs with focus trap and backdrop handlers.
|
|
33
|
+
- `navigate`: Client-side or browser redirects with URL interpolation.
|
|
34
|
+
- `custom`: Extensible hooks for application-specific action handlers.
|
|
35
|
+
- **Form Runtime Context**: `FormRuntimeProvider` and `useFormRuntime` for state management, field binding, live validation, and submission handling.
|
|
36
|
+
- **Dynamic CSS & Animations**: Computes responsive styles across breakpoints (desktop, tablet, mobile), hover/focus pseudo-states, and keyframe animations.
|
|
37
|
+
- **Security & XSS Defense**: Sanitizes dangerous `javascript:`, `data:text/html` URLs and prevents CSS injection.
|
|
38
|
+
- **Code Generator**: Compiles KUBUILD document trees into production-ready standalone React JSX and Tailwind CSS code.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🚀 Quick Usage
|
|
43
|
+
|
|
44
|
+
### Rendering a Page Document
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import React from 'react';
|
|
48
|
+
import { Renderer } from '@kubuild/renderer';
|
|
49
|
+
import type { PageDocument } from '@kubuild/schema';
|
|
50
|
+
|
|
51
|
+
interface PageViewerProps {
|
|
52
|
+
document: PageDocument;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const PageViewer: React.FC<PageViewerProps> = ({ document }) => {
|
|
56
|
+
return (
|
|
57
|
+
<div className="page-container">
|
|
58
|
+
<Renderer
|
|
59
|
+
document={document}
|
|
60
|
+
onAction={(action, context) => {
|
|
61
|
+
console.log('Action triggered:', action.name, context);
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Rendering with Toast Feedback & Action Dispatcher
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import React from 'react';
|
|
73
|
+
import { Renderer, ToastContainer } from '@kubuild/renderer';
|
|
74
|
+
import type { PageDocument } from '@kubuild/schema';
|
|
75
|
+
|
|
76
|
+
export const InteractiveApp: React.FC<{ doc: PageDocument }> = ({ doc }) => {
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
<Renderer document={doc} />
|
|
80
|
+
{/* Toast container renders feedback notifications triggered by actions */}
|
|
81
|
+
<ToastContainer position="top-right" />
|
|
82
|
+
</>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Generating Standalone React Code
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { generateReactCode } from '@kubuild/renderer';
|
|
91
|
+
import type { PageDocument } from '@kubuild/schema';
|
|
92
|
+
|
|
93
|
+
const tsxCode: string = generateReactCode(pageDocument.document, {
|
|
94
|
+
framework: 'react',
|
|
95
|
+
styling: 'tailwind'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
console.log(tsxCode);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 📄 License
|
|
104
|
+
|
|
105
|
+
MIT © [KUBUILD](https://github.com/kustora/kubuild)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { PageDocument, Node, ActionTriggerType } from '@kubuild/schema';
|
|
2
|
+
import { ActionPipelineExecutor, type Diagnostic } from '@kubuild/core';
|
|
3
|
+
import type { RenderContext } from './render-context';
|
|
4
|
+
import type { FormRuntimeContextValue } from './form-context';
|
|
5
|
+
/**
|
|
6
|
+
* Options for executing node action pipelines.
|
|
7
|
+
*/
|
|
8
|
+
export interface ExecuteNodeActionsOptions {
|
|
9
|
+
node: Node;
|
|
10
|
+
trigger: ActionTriggerType | string;
|
|
11
|
+
document?: PageDocument;
|
|
12
|
+
context?: RenderContext;
|
|
13
|
+
formContext?: FormRuntimeContextValue | null;
|
|
14
|
+
extraContext?: Record<string, unknown>;
|
|
15
|
+
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
16
|
+
onActionDispatch?: (actionType: string, payload: Record<string, unknown> | undefined, nodeId: string) => void;
|
|
17
|
+
executor?: ActionPipelineExecutor;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Execution outcome from executeNodeActions.
|
|
21
|
+
*/
|
|
22
|
+
export interface NodeActionExecutionOutcome {
|
|
23
|
+
executed: boolean;
|
|
24
|
+
success: boolean;
|
|
25
|
+
error?: unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Executes all action pipelines defined on a node that match a specific trigger.
|
|
29
|
+
*/
|
|
30
|
+
export declare function executeNodeActions(options: ExecuteNodeActionsOptions): Promise<NodeActionExecutionOutcome>;
|
|
31
|
+
/**
|
|
32
|
+
* Hook to execute `load` lifecycle action pipelines on component mount.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useNodeLoadActions(node: Node, options: {
|
|
35
|
+
document?: PageDocument;
|
|
36
|
+
context?: RenderContext;
|
|
37
|
+
formContext?: FormRuntimeContextValue | null;
|
|
38
|
+
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
39
|
+
onActionDispatch?: (actionType: string, payload: Record<string, unknown> | undefined, nodeId: string) => void;
|
|
40
|
+
mode?: 'editor' | 'runtime';
|
|
41
|
+
}): void;
|
|
42
|
+
//# sourceMappingURL=action-dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-dispatcher.d.ts","sourceRoot":"","sources":["../src/action-dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,EAAkB,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,sBAAsB,E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AAC;IAChD,gBAAgB,CAAC,EAAE,CACjB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC5C,MAAM,EAAE,MAAM,KACX,IAAI,CAAC;IACV,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC7B,GACA,IAAI,CA2CN"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type PipelineStepHandler } from '@kubuild/core';
|
|
2
|
+
/**
|
|
3
|
+
* Standard API Request Response representation.
|
|
4
|
+
*/
|
|
5
|
+
export interface ApiRequestResponse<T = unknown> {
|
|
6
|
+
ok: boolean;
|
|
7
|
+
status: number;
|
|
8
|
+
statusText: string;
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
data: T;
|
|
11
|
+
body: T;
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Details passed to ApiRequestError.
|
|
16
|
+
*/
|
|
17
|
+
export interface ApiRequestErrorDetails {
|
|
18
|
+
status?: number;
|
|
19
|
+
statusText?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
method?: string;
|
|
22
|
+
data?: unknown;
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
response?: ApiRequestResponse;
|
|
25
|
+
isTimeout?: boolean;
|
|
26
|
+
isCancelled?: boolean;
|
|
27
|
+
isNetworkError?: boolean;
|
|
28
|
+
stepId?: string;
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Custom Error thrown when an API request fails, times out, or returns a non-2xx status code.
|
|
33
|
+
*/
|
|
34
|
+
export declare class ApiRequestError extends Error {
|
|
35
|
+
readonly status?: number;
|
|
36
|
+
readonly statusText?: string;
|
|
37
|
+
readonly url?: string;
|
|
38
|
+
readonly method?: string;
|
|
39
|
+
readonly data?: unknown;
|
|
40
|
+
readonly headers?: Record<string, string>;
|
|
41
|
+
readonly response?: ApiRequestResponse;
|
|
42
|
+
readonly isTimeout: boolean;
|
|
43
|
+
readonly isCancelled: boolean;
|
|
44
|
+
readonly isNetworkError: boolean;
|
|
45
|
+
readonly stepId?: string;
|
|
46
|
+
readonly cause?: unknown;
|
|
47
|
+
constructor(message: string, details?: ApiRequestErrorDetails);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for configuring API Request Action Runner.
|
|
51
|
+
*/
|
|
52
|
+
export interface ApiRequestRunnerOptions {
|
|
53
|
+
fetchFn?: typeof fetch;
|
|
54
|
+
defaultTimeout?: number;
|
|
55
|
+
baseUrl?: string;
|
|
56
|
+
headers?: Record<string, string>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Builds and validates the final API request URL with query parameters.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildApiUrl(rawUrl: string, queryParams?: Record<string, unknown>, baseUrl?: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Prepares the request body and normalizes headers based on body payload and body format.
|
|
64
|
+
*/
|
|
65
|
+
export declare function prepareRequestBody(method: string, body: unknown, bodyFormat?: string, headers?: Record<string, string>): {
|
|
66
|
+
body: BodyInit | undefined;
|
|
67
|
+
headers: Record<string, string>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Creates an API Request Step Handler configured with custom options or default settings.
|
|
71
|
+
*/
|
|
72
|
+
export declare function createApiRequestHandler(options?: ApiRequestRunnerOptions): PipelineStepHandler;
|
|
73
|
+
/**
|
|
74
|
+
* Default built-in API Request Runner instance.
|
|
75
|
+
*/
|
|
76
|
+
export declare const apiRequestRunner: PipelineStepHandler;
|
|
77
|
+
//# sourceMappingURL=api-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-request.d.ts","sourceRoot":"","sources":["../../src/action-runners/api-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB;;GA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-request';
|
|
3
|
+
export * from './api-request';
|
|
4
|
+
export * from './toast-manager';
|
|
5
|
+
export * from './toast-container';
|
|
6
|
+
export * from './modal-manager';
|
|
7
|
+
export * from './ui-feedback';
|
|
8
|
+
export * from './navigation-utils';
|
|
9
|
+
/**
|
|
10
|
+
* Options for configuring built-in action runners.
|
|
11
|
+
*/
|
|
12
|
+
export interface ActionRunnerFactoryOptions {
|
|
13
|
+
apiRequest?: ApiRequestRunnerOptions;
|
|
14
|
+
handlers?: Record<string, PipelineStepHandler>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a map of all default built-in action runners for `@kubuild/renderer`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createDefaultActionRunners(options?: ActionRunnerFactoryOptions): Record<string, PipelineStepHandler>;
|
|
20
|
+
/**
|
|
21
|
+
* Registers default built-in action runners onto an ActionPipelineExecutor instance.
|
|
22
|
+
*/
|
|
23
|
+
export declare function registerDefaultActionRunners(executor: ActionPipelineExecutor, options?: ActionRunnerFactoryOptions): ActionPipelineExecutor;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/action-runners/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,eAAe,CAAC;AAIvB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,0BAA0B,GACnC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAgBrC;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,sBAAsB,EAChC,OAAO,CAAC,EAAE,0BAA0B,GACnC,sBAAsB,CAQxB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export type ModalState = Record<string, boolean>;
|
|
2
|
+
export type ModalListener = (modals: ModalState) => void;
|
|
3
|
+
/**
|
|
4
|
+
* ModalManager manages visibility state of modals, stack ordering, and custom events.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ModalManager {
|
|
7
|
+
private modals;
|
|
8
|
+
private activeStack;
|
|
9
|
+
private listeners;
|
|
10
|
+
/**
|
|
11
|
+
* Opens a modal dialog by ID.
|
|
12
|
+
*/
|
|
13
|
+
openModal(modalId: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Closes a modal dialog by ID or closes the topmost modal if no ID is specified.
|
|
16
|
+
*/
|
|
17
|
+
closeModal(modalId?: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Toggles visibility state of a modal.
|
|
20
|
+
*/
|
|
21
|
+
toggleModal(modalId: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether a modal is currently open.
|
|
24
|
+
*/
|
|
25
|
+
isModalOpen(modalId: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks whether a modal id has ever been explicitly opened/closed,
|
|
28
|
+
* distinguishing "never touched" from "explicitly closed".
|
|
29
|
+
*/
|
|
30
|
+
hasState(modalId: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a snapshot map of all modal states.
|
|
33
|
+
*/
|
|
34
|
+
getState(): ModalState;
|
|
35
|
+
/**
|
|
36
|
+
* Returns list of currently open modal IDs in stack order.
|
|
37
|
+
*/
|
|
38
|
+
getActiveModals(): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Resets all modal states to closed.
|
|
41
|
+
*/
|
|
42
|
+
reset(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Subscribes a listener to modal state changes.
|
|
45
|
+
*/
|
|
46
|
+
subscribe(listener: ModalListener): () => void;
|
|
47
|
+
private notify;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Singleton ModalManager instance.
|
|
51
|
+
*/
|
|
52
|
+
export declare const modalManager: ModalManager;
|
|
53
|
+
/**
|
|
54
|
+
* React hook to observe and manipulate a single modal dialog state.
|
|
55
|
+
*/
|
|
56
|
+
export declare function useModal(modalId: string, manager?: ModalManager): {
|
|
57
|
+
isOpen: boolean;
|
|
58
|
+
open: () => void;
|
|
59
|
+
close: () => void;
|
|
60
|
+
toggle: () => boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* React hook to observe and manage all modal dialogs.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useModals(manager?: ModalManager): {
|
|
66
|
+
modals: ModalState;
|
|
67
|
+
activeModals: string[];
|
|
68
|
+
isOpen: (modalId: string) => boolean;
|
|
69
|
+
openModal: (modalId: string) => void;
|
|
70
|
+
closeModal: (modalId?: string) => void;
|
|
71
|
+
toggleModal: (modalId: string) => boolean;
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=modal-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal-manager.d.ts","sourceRoot":"","sources":["../../src/action-runners/modal-manager.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjD,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAEzD;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,SAAS,CAA4B;IAE7C;;OAE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
|
|
1
|
+
import { type PipelineStepHandler } from '@kubuild/core';
|
|
2
|
+
/**
|
|
3
|
+
* Result returned by navigate runner.
|
|
4
|
+
*/
|
|
5
|
+
export interface NavigateResult {
|
|
6
|
+
url: string;
|
|
7
|
+
target?: string;
|
|
8
|
+
replace?: boolean;
|
|
9
|
+
scroll?: boolean;
|
|
10
|
+
behavior?: 'smooth' | 'auto';
|
|
11
|
+
navigated: boolean;
|
|
12
|
+
isAnchor: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Result returned by copy_clipboard runner.
|
|
16
|
+
*/
|
|
17
|
+
export interface CopyClipboardResult {
|
|
18
|
+
text: string;
|
|
19
|
+
copied: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Result returned by reset_form runner.
|
|
23
|
+
*/
|
|
24
|
+
export interface ResetFormResult {
|
|
25
|
+
formId?: string;
|
|
26
|
+
reset: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Helper to copy text to clipboard with legacy fallback.
|
|
30
|
+
*/
|
|
31
|
+
export declare function copyToClipboard(text: string, options?: {
|
|
32
|
+
copyFn?: (text: string) => Promise<void> | void;
|
|
33
|
+
}): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Action Runner for `navigate`.
|
|
36
|
+
* Supports external redirects, target windows (_blank), SPA navigate hooks, and smooth anchor scrolling (#id).
|
|
37
|
+
*/
|
|
38
|
+
export declare const navigateRunner: PipelineStepHandler;
|
|
39
|
+
/**
|
|
40
|
+
* Action Runner for `copy_clipboard`.
|
|
41
|
+
* Copies string or variable payload to user clipboard with fallback and optional toast notification.
|
|
42
|
+
*/
|
|
43
|
+
export declare const copyClipboardRunner: PipelineStepHandler;
|
|
44
|
+
/**
|
|
45
|
+
* Action Runner for `reset_form`.
|
|
46
|
+
* Resets form context values and DOM form elements to default state.
|
|
47
|
+
*/
|
|
48
|
+
export declare const resetFormRunner: PipelineStepHandler;
|
|
49
|
+
//# sourceMappingURL=navigation-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-utils.d.ts","sourceRoot":"","sources":["../../src/action-runners/navigation-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiC,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGxF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAAE,GAC5D,OAAO,CAAC,OAAO,CAAC,CA0ClB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,mBA8G5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,mBAwCjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,mBAqC7B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ToastItem, type ToastPosition, type ToastManager as ToastManagerClass } from './toast-manager';
|
|
3
|
+
export interface ToastContainerProps {
|
|
4
|
+
manager?: ToastManagerClass;
|
|
5
|
+
position?: ToastPosition;
|
|
6
|
+
className?: string;
|
|
7
|
+
maxVisible?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Single Toast Item component rendering an alert card.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ToastCard: React.FC<{
|
|
13
|
+
toast: ToastItem;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Built-in responsive Toast Container component.
|
|
17
|
+
* Renders floating toasts with smooth animations and auto-dismiss capabilities.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ToastContainer: React.FC<ToastContainerProps>;
|
|
20
|
+
//# sourceMappingURL=toast-container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-container.d.ts","sourceRoot":"","sources":["../../src/action-runners/toast-container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,aAAa,EAElB,KAAK,YAAY,IAAI,iBAAiB,EACvC,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkFD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,CA8EpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA6ExD,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type ToastType = 'success' | 'error' | 'warning' | 'info';
|
|
2
|
+
export type ToastPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for spawning a toast notification.
|
|
5
|
+
*/
|
|
6
|
+
export interface ToastOptions {
|
|
7
|
+
message: string;
|
|
8
|
+
type?: ToastType;
|
|
9
|
+
variant?: ToastType;
|
|
10
|
+
title?: string;
|
|
11
|
+
duration?: number;
|
|
12
|
+
position?: ToastPosition;
|
|
13
|
+
dismissible?: boolean;
|
|
14
|
+
id?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Internal active toast item structure.
|
|
18
|
+
*/
|
|
19
|
+
export interface ToastItem {
|
|
20
|
+
id: string;
|
|
21
|
+
type: ToastType;
|
|
22
|
+
message: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
duration: number;
|
|
25
|
+
position: ToastPosition;
|
|
26
|
+
dismissible: boolean;
|
|
27
|
+
createdAt: number;
|
|
28
|
+
dismiss: () => void;
|
|
29
|
+
}
|
|
30
|
+
type ToastListener = (toasts: ToastItem[]) => void;
|
|
31
|
+
/**
|
|
32
|
+
* ToastManager manages reactive toast state, timers, and event subscriptions.
|
|
33
|
+
*/
|
|
34
|
+
export declare class ToastManager {
|
|
35
|
+
private toasts;
|
|
36
|
+
private listeners;
|
|
37
|
+
private timers;
|
|
38
|
+
/**
|
|
39
|
+
* Spawns a new toast notification.
|
|
40
|
+
*/
|
|
41
|
+
showToast(options: ToastOptions | string): ToastItem;
|
|
42
|
+
/**
|
|
43
|
+
* Dismisses a single toast by ID.
|
|
44
|
+
*/
|
|
45
|
+
dismissToast(id: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Clears all active toasts.
|
|
48
|
+
*/
|
|
49
|
+
clearToasts(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Returns current active toasts.
|
|
52
|
+
*/
|
|
53
|
+
getToasts(): ToastItem[];
|
|
54
|
+
/**
|
|
55
|
+
* Subscribes a listener to toast state changes.
|
|
56
|
+
*/
|
|
57
|
+
subscribe(listener: ToastListener): () => void;
|
|
58
|
+
private notify;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Singleton ToastManager instance for global toast handling.
|
|
62
|
+
*/
|
|
63
|
+
export declare const toastManager: ToastManager;
|
|
64
|
+
/**
|
|
65
|
+
* React hook to observe and trigger toast notifications.
|
|
66
|
+
*/
|
|
67
|
+
export declare function useToasts(manager?: ToastManager): {
|
|
68
|
+
toasts: ToastItem[];
|
|
69
|
+
showToast: (options: ToastOptions | string) => ToastItem;
|
|
70
|
+
dismissToast: (id: string) => void;
|
|
71
|
+
clearToasts: () => void;
|
|
72
|
+
};
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=toast-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-manager.d.ts","sourceRoot":"","sources":["../../src/action-runners/toast-manager.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACjE,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,UAAU,GACV,cAAc,GACd,aAAa,GACb,YAAY,GACZ,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,aAAa,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,KAAK,aAAa,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;AAInD;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,MAAM,CAAoD;IAElE;;OAEG;IACI,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS;IA2C3D;;OAEG;IACI,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAcrC;;OAEG;IACI,WAAW,IAAI,IAAI;IAS1B;;OAEG;IACI,SAAS,IAAI,SAAS,EAAE;IAI/B;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAOrD,OAAO,CAAC,MAAM;CAUf;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,cAAqB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,YAA2B,GAAG;IAC/D,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,KAAK,SAAS,CAAC;IACzD,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAgBA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type PipelineStepHandler } from '@kubuild/core';
|
|
2
|
+
import { type ToastType, type ToastPosition } from './toast-manager';
|
|
3
|
+
/**
|
|
4
|
+
* Result returned by show_toast runner.
|
|
5
|
+
*/
|
|
6
|
+
export interface ShowToastResult {
|
|
7
|
+
id: string;
|
|
8
|
+
message: string;
|
|
9
|
+
type: ToastType;
|
|
10
|
+
title?: string;
|
|
11
|
+
duration: number;
|
|
12
|
+
position: ToastPosition;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Result returned by open_modal or close_modal runner.
|
|
16
|
+
*/
|
|
17
|
+
export interface ModalActionResult {
|
|
18
|
+
modalId: string;
|
|
19
|
+
open: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Action Runner for `show_toast`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const showToastRunner: PipelineStepHandler;
|
|
25
|
+
/**
|
|
26
|
+
* Action Runner for `open_modal`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const openModalRunner: PipelineStepHandler;
|
|
29
|
+
/**
|
|
30
|
+
* Action Runner for `toggle_modal`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const toggleModalRunner: PipelineStepHandler;
|
|
33
|
+
/**
|
|
34
|
+
* Action Runner for `close_modal`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const closeModalRunner: PipelineStepHandler;
|
|
37
|
+
//# sourceMappingURL=ui-feedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-feedback.d.ts","sourceRoot":"","sources":["../../src/action-runners/ui-feedback.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAmC,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGtG;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,mBAqC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,mBAmC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,mBAc/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,mBAqC9B,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Artboard, Node } from '@kubuild/schema';
|
|
3
|
+
import { type ComponentRegistry } from '@kubuild/components';
|
|
4
|
+
import { RenderContext, Diagnostic } from './render-context';
|
|
5
|
+
import { type ModalManager } from './action-runners';
|
|
6
|
+
import { type KubuildRendererProps } from './renderer';
|
|
7
|
+
export interface ArtboardPortalHostProps {
|
|
8
|
+
/**
|
|
9
|
+
* Component artboards eligible for portal rendering. Defaults to
|
|
10
|
+
* `context.componentArtboards` when omitted.
|
|
11
|
+
*/
|
|
12
|
+
artboards?: readonly Artboard[];
|
|
13
|
+
registry?: ComponentRegistry;
|
|
14
|
+
context?: RenderContext;
|
|
15
|
+
viewport?: 'desktop' | 'tablet' | 'mobile';
|
|
16
|
+
/**
|
|
17
|
+
* Editor mode renders nothing: while authoring, a component artboard is shown as its own
|
|
18
|
+
* canvas surface instead, which is precisely what keeps it from covering the page being
|
|
19
|
+
* edited. Portals exist only for runtime/preview.
|
|
20
|
+
*/
|
|
21
|
+
mode?: 'editor' | 'runtime';
|
|
22
|
+
modalManager?: ModalManager;
|
|
23
|
+
/** Portal target; defaults to `document.body`. */
|
|
24
|
+
container?: Element | null;
|
|
25
|
+
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
26
|
+
onActionDispatch?: (actionType: string, payload: Record<string, unknown> | undefined, nodeId: string) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns the node a component artboard actually represents: its synthetic `page` root
|
|
30
|
+
* holds the detached subtree as its only child.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getArtboardContentNode(artboard: Artboard): Node | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Pick the component artboards that should currently be on screen, given ModalManager's
|
|
35
|
+
* state snapshot. Kept as a pure function so the open/closed decision is testable without
|
|
36
|
+
* a DOM, and so the portal component itself stays a thin shell around it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function selectOpenComponentArtboards(artboards: readonly Artboard[], modalState: Record<string, boolean>): Artboard[];
|
|
39
|
+
/**
|
|
40
|
+
* Renders every open component artboard into a portal.
|
|
41
|
+
*
|
|
42
|
+
* Detaching a modal/drawer into its own artboard means its content is no longer part of the
|
|
43
|
+
* page's own node tree, so at runtime something has to put it back on screen when a trigger
|
|
44
|
+
* fires. ModalManager is a plain string-keyed singleton, so a trigger in one artboard already
|
|
45
|
+
* addresses content in another with no extra wiring — this host just watches that state and
|
|
46
|
+
* renders whichever component artboards are currently open.
|
|
47
|
+
*/
|
|
48
|
+
export declare const ArtboardPortalHost: React.FC<ArtboardPortalHostProps>;
|
|
49
|
+
export interface KubuildProjectRendererProps extends KubuildRendererProps {
|
|
50
|
+
/**
|
|
51
|
+
* Component artboards belonging to the same project as `document`. Their content is
|
|
52
|
+
* portal-rendered on top of the page whenever a trigger opens them (runtime only).
|
|
53
|
+
* Defaults to `context.componentArtboards`.
|
|
54
|
+
*/
|
|
55
|
+
componentArtboards?: readonly Artboard[];
|
|
56
|
+
modalManager?: ModalManager;
|
|
57
|
+
portalContainer?: Element | null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Renders one page artboard plus the portal host for its project's component artboards.
|
|
61
|
+
*
|
|
62
|
+
* Use this instead of KubuildRenderer wherever a published page must be able to open
|
|
63
|
+
* detached modals/drawers. Dependency direction stays one-way (this composes the renderer;
|
|
64
|
+
* the renderer knows nothing about projects), so single-document rendering is unaffected.
|
|
65
|
+
*/
|
|
66
|
+
export declare const KubuildProjectRenderer: React.FC<KubuildProjectRendererProps>;
|
|
67
|
+
//# sourceMappingURL=artboard-portal-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artboard-portal-host.d.ts","sourceRoot":"","sources":["../src/artboard-portal-host.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,KAAK,iBAAiB,EAAkC,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAA0B,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAiC,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEtF,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3C;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAChD,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/G;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,CAI3E;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,SAAS,QAAQ,EAAE,EAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,QAAQ,EAAE,CAQZ;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA6EhE,CAAC;AAEF,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IACzC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAsBxE,CAAC"}
|
package/dist/error-boundary.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
import type { Diagnostic } from './render-context';
|
|
2
3
|
export interface ComponentErrorBoundaryProps {
|
|
3
4
|
nodeId: string;
|
|
4
5
|
componentType: string;
|
|
5
6
|
mode?: 'editor' | 'runtime';
|
|
6
7
|
children: ReactNode;
|
|
7
8
|
onError?: (error: Error, info: ErrorInfo) => void;
|
|
9
|
+
onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
8
10
|
}
|
|
9
11
|
interface ComponentErrorBoundaryState {
|
|
10
12
|
hasError: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../src/error-boundary.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../src/error-boundary.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;CACjD;AAED,UAAU,2BAA2B;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,qBAAa,sBAAuB,SAAQ,SAAS,CACnD,2BAA2B,EAC3B,2BAA2B,CAC5B;gBACa,KAAK,EAAE,2BAA2B;IAK9C,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,2BAA2B;IAI1E,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAe3D,MAAM,IAAI,SAAS;CA8CpB"}
|