@mochabug/adapt-react 1.0.0-rc1 → 1.0.0-rc3

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 CHANGED
@@ -11,15 +11,15 @@ Requires React 17, 18, or 19.
11
11
  ## Quickstart
12
12
 
13
13
  ```tsx
14
- import { AdaptAutomation } from '@mochabug/adapt-react';
14
+ import { Adapt } from '@mochabug/adapt-react';
15
15
 
16
- <AdaptAutomation id="auto-123" style={{ height: 600 }} />
16
+ <Adapt id="auto-123" style={{ height: 600 }} />
17
17
  ```
18
18
 
19
19
  If the automation requires authentication:
20
20
 
21
21
  ```tsx
22
- <AdaptAutomation id="auto-123" authToken="your-token" style={{ height: 600 }} />
22
+ <Adapt id="auto-123" authToken="your-token" style={{ height: 600 }} />
23
23
  ```
24
24
 
25
25
  ## SSR (Next.js)
@@ -39,16 +39,10 @@ export default async function Page() {
39
39
 
40
40
  // components/AutomationClient.tsx (Client Component)
41
41
  'use client';
42
- import { AdaptAutomation } from '@mochabug/adapt-react';
42
+ import { Adapt } from '@mochabug/adapt-react';
43
43
 
44
44
  export function AutomationClient({ sessionToken }) {
45
- return (
46
- <AdaptAutomation
47
- id="auto-123"
48
- sessionToken={sessionToken}
49
- style={{ height: 600 }}
50
- />
51
- );
45
+ return <Adapt id="auto-123" sessionToken={sessionToken} style={{ height: 600 }} />;
52
46
  }
53
47
  ```
54
48
 
@@ -56,40 +50,64 @@ export function AutomationClient({ sessionToken }) {
56
50
 
57
51
  ```tsx
58
52
  // direct
59
- <AdaptAutomation id="auto-123" inheritToken="token-from-parent" />
53
+ <Adapt id="auto-123" inheritToken="token-from-parent" />
60
54
 
61
55
  // from URL hash: example.com#mb_session=xxx
62
- <AdaptAutomation id="auto-123" inheritFrom={{ hash: 'mb_session' }} />
56
+ <Adapt id="auto-123" inheritFrom={{ hash: 'mb_session' }} />
63
57
  ```
64
58
 
65
59
  ## Fork display
66
60
 
67
61
  ```tsx
68
62
  // side-by-side
69
- <AdaptAutomation
70
- id="auto-123"
71
- forkDisplayMode="side-by-side"
72
- sideBySideSplit={60}
73
- />
63
+ <Adapt id="auto-123" forkDisplayMode="side-by-side" sideBySideSplit={60} />
74
64
 
75
65
  // dialog
76
- <AdaptAutomation
77
- id="auto-123"
78
- forkDisplayMode="dialog"
79
- dialogBackdropClose
80
- />
66
+ <Adapt id="auto-123" forkDisplayMode="dialog" dialogBackdropClose />
81
67
  ```
82
68
 
83
69
  ## Callbacks
84
70
 
85
71
  ```tsx
86
- <AdaptAutomation
72
+ <Adapt
87
73
  id="auto-123"
88
74
  onSession={(status, fork) => console.log(status, fork)}
89
75
  onOutput={(output) => console.log(output)}
90
76
  />
91
77
  ```
92
78
 
79
+ ## Advanced: Multiple transmitters or initial signals
80
+
81
+ For automations with multiple entry points or when you need to pass initial data:
82
+
83
+ ```tsx
84
+ import { Adapt, type SignalDataJson } from '@mochabug/adapt-react';
85
+
86
+ // Start from a specific transmitter
87
+ <Adapt
88
+ id="auto-123"
89
+ authToken="your-token"
90
+ transmitter="my-transmitter"
91
+ style={{ height: 600 }}
92
+ />
93
+
94
+ // Start with initial signals (data must be base64 encoded)
95
+ const signals: { [key: string]: SignalDataJson } = {
96
+ 'input': {
97
+ mimeType: 'text/plain',
98
+ data: btoa('Hello World')
99
+ }
100
+ };
101
+
102
+ <Adapt
103
+ id="auto-123"
104
+ authToken="your-token"
105
+ transmitter="file-processor"
106
+ signals={signals}
107
+ style={{ height: 600 }}
108
+ />
109
+ ```
110
+
93
111
  ## Props
94
112
 
95
113
  | Prop | Type |
@@ -97,6 +115,8 @@ export function AutomationClient({ sessionToken }) {
97
115
  | `id` | `string` (required) |
98
116
  | `sessionToken` | `string` |
99
117
  | `authToken` | `string` |
118
+ | `transmitter` | `string` |
119
+ | `signals` | `{ [key: string]: SignalDataJson }` |
100
120
  | `inheritToken` | `string` |
101
121
  | `inheritFrom` | `{ hash: string } \| { param: string }` |
102
122
  | `forkDisplayMode` | `'side-by-side' \| 'dialog'` |
package/dist/esm/index.js CHANGED
@@ -1,43 +1,19 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useRef, forwardRef } from "react";
3
2
  import { AdaptWebClient, } from "@mochabug/adapt-web";
3
+ import { forwardRef, useEffect, useRef } from "react";
4
+ // Re-export everything from web
5
+ export * from "@mochabug/adapt-web";
4
6
  /**
5
7
  * React component for embedding Adapt automations.
6
- *
7
- * @example
8
- * ```tsx
9
- * import { AdaptAutomation } from '@mochabug/adapt-react';
10
- *
11
- * function App() {
12
- * return (
13
- * <AdaptAutomation
14
- * id="automation-123"
15
- * style={{ height: '600px' }}
16
- * onSession={(status) => console.log('Status:', status)}
17
- * />
18
- * );
19
- * }
20
- * ```
21
- *
22
- * @example
23
- * ```tsx
24
- * // With session inheritance from URL hash
25
- * <AdaptAutomation
26
- * id="automation-123"
27
- * inheritFrom={{ hash: 'mb_session' }}
28
- * style={{ height: '100vh' }}
29
- * />
30
- * ```
31
8
  */
32
- export const AdaptAutomation = forwardRef(function AdaptAutomation({ id, sessionToken, authToken, inheritToken, inheritFrom, forkDisplayMode, sideBySideSplit, dialogBackdropClose, onSession, onOutput, classNames, className, style, }, ref) {
9
+ export const Adapt = forwardRef(function Adapt({ id, sessionToken, authToken, transmitter, signals, inheritToken, inheritFrom, forkDisplayMode, sideBySideSplit, dialogBackdropClose, onSession, onOutput, classNames, className, style, }, ref) {
33
10
  const clientRef = useRef(null);
34
11
  const internalRef = useRef(null);
35
12
  const containerIdRef = useRef(`adapt-${Math.random().toString(36).slice(2, 11)}`);
36
13
  const containerId = containerIdRef.current;
37
14
  // Merge refs
38
15
  const setRef = (element) => {
39
- internalRef.current =
40
- element;
16
+ internalRef.current = element;
41
17
  if (typeof ref === "function") {
42
18
  ref(element);
43
19
  }
@@ -51,6 +27,8 @@ export const AdaptAutomation = forwardRef(function AdaptAutomation({ id, session
51
27
  id,
52
28
  sessionToken,
53
29
  authToken,
30
+ transmitter,
31
+ signals,
54
32
  inheritToken,
55
33
  inheritFrom,
56
34
  forkDisplayMode,
@@ -65,7 +43,6 @@ export const AdaptAutomation = forwardRef(function AdaptAutomation({ id, session
65
43
  clientRef.current = null;
66
44
  };
67
45
  // Only recreate client if automation ID changes
68
- // eslint-disable-next-line react-hooks/exhaustive-deps
69
46
  }, [id]);
70
47
  return (_jsx("div", { ref: setRef, id: containerId, className: className, style: style }));
71
48
  });
@@ -1,10 +1,9 @@
1
1
  import { type AdaptWebClientOptions } from "@mochabug/adapt-web";
2
- import type { Output, StatusJson } from "@mochabug/adapt-core";
3
- export type { Output, StatusJson };
2
+ export * from "@mochabug/adapt-web";
4
3
  /**
5
- * Props for the AdaptAutomation React component.
4
+ * Props for the Adapt React component.
6
5
  */
7
- export interface AdaptAutomationProps extends Pick<AdaptWebClientOptions, "id" | "sessionToken" | "authToken" | "inheritToken" | "inheritFrom" | "forkDisplayMode" | "sideBySideSplit" | "dialogBackdropClose" | "onSession" | "onOutput" | "classNames"> {
6
+ export interface AdaptProps extends Pick<AdaptWebClientOptions, "id" | "sessionToken" | "authToken" | "transmitter" | "signals" | "inheritToken" | "inheritFrom" | "forkDisplayMode" | "sideBySideSplit" | "dialogBackdropClose" | "onSession" | "onOutput" | "classNames"> {
8
7
  /** CSS class name for the container */
9
8
  className?: string;
10
9
  /** Inline styles for the container */
@@ -12,30 +11,5 @@ export interface AdaptAutomationProps extends Pick<AdaptWebClientOptions, "id" |
12
11
  }
13
12
  /**
14
13
  * React component for embedding Adapt automations.
15
- *
16
- * @example
17
- * ```tsx
18
- * import { AdaptAutomation } from '@mochabug/adapt-react';
19
- *
20
- * function App() {
21
- * return (
22
- * <AdaptAutomation
23
- * id="automation-123"
24
- * style={{ height: '600px' }}
25
- * onSession={(status) => console.log('Status:', status)}
26
- * />
27
- * );
28
- * }
29
- * ```
30
- *
31
- * @example
32
- * ```tsx
33
- * // With session inheritance from URL hash
34
- * <AdaptAutomation
35
- * id="automation-123"
36
- * inheritFrom={{ hash: 'mb_session' }}
37
- * style={{ height: '100vh' }}
38
- * />
39
- * ```
40
14
  */
41
- export declare const AdaptAutomation: import("react").ForwardRefExoticComponent<AdaptAutomationProps & import("react").RefAttributes<HTMLDivElement>>;
15
+ export declare const Adapt: import("react").ForwardRefExoticComponent<AdaptProps & import("react").RefAttributes<HTMLDivElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mochabug/adapt-react",
3
- "version": "1.0.0-rc1",
3
+ "version": "1.0.0-rc3",
4
4
  "description": "React component for Adapt automation platform",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -37,6 +37,6 @@
37
37
  "typescript": "^5.9.3"
38
38
  },
39
39
  "dependencies": {
40
- "@mochabug/adapt-web": "^1.0.0-rc22"
40
+ "@mochabug/adapt-web": "^1.0.0-rc24"
41
41
  }
42
42
  }