@mochabug/adapt-astro 1.0.1-rc.21 → 1.0.1-rc.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mochabug/adapt-astro",
3
- "version": "1.0.1-rc.21",
3
+ "version": "1.0.1-rc.23",
4
4
  "description": "Astro component for Adapt automation platform",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -18,7 +18,9 @@
18
18
  "types": "./src/cap.ts",
19
19
  "import": "./src/cap.ts"
20
20
  },
21
- "./AdaptAutomation.astro": "./src/AdaptAutomation.astro"
21
+ "./AdaptAutomation.astro": "./src/AdaptAutomation.astro",
22
+ "./AdaptAutomationCore.astro": "./src/AdaptAutomationCore.astro",
23
+ "./AdaptCap.astro": "./src/AdaptCap.astro"
22
24
  },
23
25
  "files": [
24
26
  "src"
@@ -39,6 +41,6 @@
39
41
  "astro": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
40
42
  },
41
43
  "dependencies": {
42
- "@mochabug/adapt-web": "^1.0.1-rc.20"
44
+ "@mochabug/adapt-web": "^1.0.1-rc.21"
43
45
  }
44
46
  }
@@ -114,7 +114,7 @@ const containerId = `adapt-${Math.random().toString(36).slice(2, 11)}`;
114
114
  </adapt-automation>
115
115
 
116
116
  <script>
117
- import { AdaptAutomationElement } from "@mochabug/adapt-web/core";
117
+ import { AdaptAutomationElement } from "@mochabug/adapt-web";
118
118
 
119
119
  // Ensure custom element is registered
120
120
  void AdaptAutomationElement;
@@ -0,0 +1,162 @@
1
+ ---
2
+ import type { AdaptWebClientOptions } from "@mochabug/adapt-web/core";
3
+
4
+ export interface Props extends Pick<
5
+ AdaptWebClientOptions,
6
+ | "automationId"
7
+ | "sessionToken"
8
+ | "authToken"
9
+ | "transmitter"
10
+ | "signals"
11
+ | "challengeToken"
12
+ | "inheritToken"
13
+ | "inheritFrom"
14
+ | "forkDisplay"
15
+ | "darkMode"
16
+ | "autoResizing"
17
+ | "allowFloating"
18
+ | "allowDocking"
19
+ | "allowDialogDocking"
20
+ | "allowMinimize"
21
+ | "allowMaximize"
22
+ | "floatingAutoResize"
23
+ | "onSession"
24
+ | "onOutput"
25
+ | "onForkActive"
26
+ | "onError"
27
+ | "classNames"
28
+ | "persist"
29
+ | "text"
30
+ | "theme"
31
+ | "debug"
32
+ > {
33
+ /** CSS class name for the container */
34
+ class?: string;
35
+ /** Inline styles for the container */
36
+ style?: string;
37
+ }
38
+
39
+ const {
40
+ automationId,
41
+ sessionToken,
42
+ authToken,
43
+ transmitter,
44
+ signals,
45
+ challengeToken,
46
+ inheritToken,
47
+ inheritFrom,
48
+ forkDisplay,
49
+ darkMode = false,
50
+ autoResizing = false,
51
+ allowFloating,
52
+ allowDocking,
53
+ allowDialogDocking,
54
+ allowMinimize,
55
+ allowMaximize,
56
+ floatingAutoResize = false,
57
+ classNames,
58
+ persist,
59
+ text,
60
+ theme,
61
+ debug = false,
62
+ class: className,
63
+ style,
64
+ } = Astro.props;
65
+
66
+ const forkDisplayMode = forkDisplay?.mode ?? "side-by-side";
67
+ const sideBySideSplit =
68
+ forkDisplay?.mode === "side-by-side" ? (forkDisplay.split ?? 50) : 50;
69
+
70
+ const containerId = `adapt-${Math.random().toString(36).slice(2, 11)}`;
71
+ ---
72
+
73
+ <adapt-automation
74
+ id={containerId}
75
+ class={className}
76
+ style={style}
77
+ automation-id={automationId}
78
+ session-token={sessionToken}
79
+ auth-token={authToken}
80
+ transmitter={transmitter}
81
+ challenge-token={challengeToken}
82
+ inherit-token={inheritToken}
83
+ fork-display-mode={forkDisplayMode}
84
+ side-by-side-split={String(sideBySideSplit)}
85
+ dark-mode={darkMode ? "" : undefined}
86
+ auto-resizing={autoResizing ? "" : undefined}
87
+ allow-floating={allowFloating === false ? "false" : undefined}
88
+ allow-docking={allowDocking === false ? "false" : undefined}
89
+ allow-dialog-docking={allowDialogDocking === false ? "false" : undefined}
90
+ allow-minimize={allowMinimize === false ? "false" : undefined}
91
+ allow-maximize={allowMaximize === false ? "false" : undefined}
92
+ floating-auto-resize={floatingAutoResize ? "" : undefined}
93
+ persist={persist ? "" : undefined}
94
+ debug={debug ? "" : undefined}
95
+ data-adapt-text={text ? JSON.stringify(text) : undefined}
96
+ data-adapt-persist-options={typeof persist === "object"
97
+ ? JSON.stringify(persist)
98
+ : undefined}
99
+ data-adapt-signals={signals ? JSON.stringify(signals) : undefined}
100
+ data-adapt-inherit-from={inheritFrom
101
+ ? JSON.stringify(inheritFrom)
102
+ : undefined}
103
+ data-adapt-class-names={classNames ? JSON.stringify(classNames) : undefined}
104
+ data-adapt-theme={theme ? JSON.stringify(theme) : undefined}
105
+ >
106
+ </adapt-automation>
107
+
108
+ <script>
109
+ import { AdaptAutomationElement } from "@mochabug/adapt-web/core";
110
+
111
+ // Ensure custom element is registered
112
+ void AdaptAutomationElement;
113
+
114
+ function initAll() {
115
+ document
116
+ .querySelectorAll<AdaptAutomationElement>("adapt-automation")
117
+ .forEach((el) => {
118
+ // Set non-serializable properties from data attributes
119
+ const signalsStr = el.dataset.adaptSignals;
120
+ if (signalsStr) {
121
+ el.signals = JSON.parse(signalsStr);
122
+ }
123
+
124
+ const inheritFromStr = el.dataset.adaptInheritFrom;
125
+ if (inheritFromStr) {
126
+ el.inheritFrom = JSON.parse(inheritFromStr);
127
+ }
128
+
129
+ const classNamesStr = el.dataset.adaptClassNames;
130
+ if (classNamesStr) {
131
+ el.classNames = JSON.parse(classNamesStr);
132
+ }
133
+
134
+ const persistStr = el.dataset.adaptPersistOptions;
135
+ if (persistStr) {
136
+ el.persistOptions = JSON.parse(persistStr);
137
+ }
138
+
139
+ const textStr = el.dataset.adaptText;
140
+ if (textStr) {
141
+ el.text = JSON.parse(textStr);
142
+ }
143
+
144
+ const themeStr = el.dataset.adaptTheme;
145
+ if (themeStr) {
146
+ el.theme = JSON.parse(themeStr);
147
+ }
148
+
149
+ // Dispatch events for callbacks (users can addEventListener on the element)
150
+ // onSession and onOutput are handled automatically via adapt-session and adapt-output CustomEvents
151
+ });
152
+ }
153
+
154
+ // Initial load
155
+ initAll();
156
+
157
+ // Handle Astro View Transitions
158
+ document.addEventListener("astro:page-load", initAll);
159
+
160
+ // Cleanup before page swap (View Transitions)
161
+ // The custom element handles its own cleanup in disconnectedCallback
162
+ </script>