@mochabug/adapt-svelte 1.0.0-rc15 → 1.0.0-rc17
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/Adapt.svelte +37 -69
- package/dist/Adapt.svelte.d.ts +1 -0
- package/dist/AdaptCap.svelte +23 -51
- package/package.json +3 -3
package/dist/Adapt.svelte
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { AdaptAutomationElement, type AdaptWebClientOptions, type Output, type SignalValue, type StatusJson } from '@mochabug/adapt-web';
|
|
3
|
+
// Ensure custom element is registered
|
|
4
|
+
void AdaptAutomationElement;
|
|
4
5
|
|
|
5
|
-
// Props interface
|
|
6
|
+
// Props interface
|
|
6
7
|
interface Props {
|
|
7
8
|
id: string;
|
|
8
9
|
sessionToken?: string;
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
darkMode?: boolean;
|
|
21
22
|
autoResizing?: boolean;
|
|
22
23
|
classNames?: AdaptWebClientOptions['classNames'];
|
|
24
|
+
styles?: Partial<CSSStyleDeclaration>;
|
|
23
25
|
onsession?: (event: { status: StatusJson; fork?: string }) => void;
|
|
24
26
|
onoutput?: (event: { output: Output }) => void;
|
|
25
27
|
[key: string]: unknown;
|
|
@@ -42,81 +44,47 @@
|
|
|
42
44
|
darkMode = false,
|
|
43
45
|
autoResizing = false,
|
|
44
46
|
classNames = undefined,
|
|
47
|
+
styles = undefined,
|
|
45
48
|
onsession,
|
|
46
49
|
onoutput,
|
|
47
50
|
...restProps
|
|
48
51
|
}: Props = $props();
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
let client: AdaptWebClient | null = null;
|
|
53
|
+
let element: AdaptAutomationElement;
|
|
52
54
|
|
|
53
|
-
function
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
challengeToken,
|
|
67
|
-
requiresChallenge,
|
|
68
|
-
capWidgetOptions,
|
|
69
|
-
inheritToken,
|
|
70
|
-
inheritFrom,
|
|
71
|
-
forkDisplayMode,
|
|
72
|
-
sideBySideSplit,
|
|
73
|
-
dialogBackdropClose,
|
|
74
|
-
darkMode,
|
|
75
|
-
autoResizing,
|
|
76
|
-
classNames,
|
|
77
|
-
onSession: (status, fork) => {
|
|
78
|
-
onsession?.({ status, fork });
|
|
79
|
-
},
|
|
80
|
-
onOutput: (output) => {
|
|
81
|
-
onoutput?.({ output });
|
|
82
|
-
},
|
|
83
|
-
});
|
|
55
|
+
function syncProperties() {
|
|
56
|
+
if (!element) return;
|
|
57
|
+
element.signals = signals;
|
|
58
|
+
element.capWidgetOptions = capWidgetOptions;
|
|
59
|
+
element.inheritFrom = inheritFrom;
|
|
60
|
+
element.classNames = classNames;
|
|
61
|
+
element.styles = styles;
|
|
62
|
+
element.onSessionCallback = (status, fork) => {
|
|
63
|
+
onsession?.({ status, fork });
|
|
64
|
+
};
|
|
65
|
+
element.onOutputCallback = (output) => {
|
|
66
|
+
onoutput?.({ output });
|
|
67
|
+
};
|
|
84
68
|
}
|
|
85
69
|
|
|
86
|
-
onMount(() => {
|
|
87
|
-
createClient();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
onDestroy(() => {
|
|
91
|
-
if (client) {
|
|
92
|
-
client.destroy();
|
|
93
|
-
client = null;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Recreate client when id changes
|
|
98
|
-
$effect(() => {
|
|
99
|
-
if (id && typeof window !== 'undefined') {
|
|
100
|
-
createClient();
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Runtime updates
|
|
105
|
-
$effect(() => {
|
|
106
|
-
client?.setDarkMode(darkMode);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
$effect(() => {
|
|
110
|
-
client?.setAutoResizing(autoResizing);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
$effect(() => {
|
|
114
|
-
client?.setForkDisplayMode(forkDisplayMode);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
70
|
$effect(() => {
|
|
118
|
-
|
|
71
|
+
syncProperties();
|
|
119
72
|
});
|
|
120
73
|
</script>
|
|
121
74
|
|
|
122
|
-
<
|
|
75
|
+
<adapt-automation
|
|
76
|
+
bind:this={element}
|
|
77
|
+
automation-id={id}
|
|
78
|
+
session-token={sessionToken}
|
|
79
|
+
auth-token={authToken}
|
|
80
|
+
transmitter={transmitter}
|
|
81
|
+
challenge-token={challengeToken}
|
|
82
|
+
requires-challenge={requiresChallenge ? '' : undefined}
|
|
83
|
+
inherit-token={inheritToken}
|
|
84
|
+
fork-display-mode={forkDisplayMode}
|
|
85
|
+
side-by-side-split={sideBySideSplit !== undefined ? String(sideBySideSplit) : undefined}
|
|
86
|
+
dialog-backdrop-close={dialogBackdropClose ? '' : undefined}
|
|
87
|
+
dark-mode={darkMode ? '' : undefined}
|
|
88
|
+
auto-resizing={autoResizing ? '' : undefined}
|
|
89
|
+
{...restProps}
|
|
90
|
+
></adapt-automation>
|
package/dist/Adapt.svelte.d.ts
CHANGED
package/dist/AdaptCap.svelte
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { AutomationClient } from '@mochabug/adapt-core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { AdaptCapElement, type CapWidgetI18n } from '@mochabug/adapt-web';
|
|
4
|
+
// Ensure custom element is registered
|
|
5
|
+
void AdaptCapElement;
|
|
5
6
|
|
|
6
7
|
// Props interface
|
|
7
8
|
interface Props {
|
|
@@ -26,58 +27,29 @@
|
|
|
26
27
|
...restProps
|
|
27
28
|
}: Props = $props();
|
|
28
29
|
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
container,
|
|
42
|
-
automationId,
|
|
43
|
-
client,
|
|
44
|
-
onSolve: (token, expires) => {
|
|
45
|
-
onsolve?.({ token, expires });
|
|
46
|
-
},
|
|
47
|
-
onError: (error) => {
|
|
48
|
-
onerror?.({ error });
|
|
49
|
-
},
|
|
50
|
-
...(workerCount !== undefined && { workerCount }),
|
|
51
|
-
...(i18n !== undefined && { i18n }),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (darkMode) {
|
|
55
|
-
widget.setDarkMode(true);
|
|
56
|
-
}
|
|
30
|
+
let element: AdaptCapElement;
|
|
31
|
+
|
|
32
|
+
function syncProperties() {
|
|
33
|
+
if (!element) return;
|
|
34
|
+
element.client = client;
|
|
35
|
+
element.i18n = i18n;
|
|
36
|
+
element.onSolveCallback = (token, expires) => {
|
|
37
|
+
onsolve?.({ token, expires });
|
|
38
|
+
};
|
|
39
|
+
element.onErrorCallback = (error) => {
|
|
40
|
+
onerror?.({ error });
|
|
41
|
+
};
|
|
57
42
|
}
|
|
58
43
|
|
|
59
|
-
onMount(() => {
|
|
60
|
-
createWidget();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
onDestroy(() => {
|
|
64
|
-
if (widget) {
|
|
65
|
-
widget.destroy();
|
|
66
|
-
widget = null;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Recreate widget when automationId or client changes
|
|
71
|
-
$effect(() => {
|
|
72
|
-
if (automationId && client && typeof window !== 'undefined') {
|
|
73
|
-
createWidget();
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Update dark mode
|
|
78
44
|
$effect(() => {
|
|
79
|
-
|
|
45
|
+
syncProperties();
|
|
80
46
|
});
|
|
81
47
|
</script>
|
|
82
48
|
|
|
83
|
-
<
|
|
49
|
+
<adapt-cap
|
|
50
|
+
bind:this={element}
|
|
51
|
+
automation-id={automationId}
|
|
52
|
+
dark-mode={darkMode ? '' : undefined}
|
|
53
|
+
worker-count={workerCount !== undefined ? String(workerCount) : undefined}
|
|
54
|
+
{...restProps}
|
|
55
|
+
></adapt-cap>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mochabug/adapt-svelte",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc17",
|
|
4
4
|
"description": "Svelte component for Adapt automation platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@sveltejs/package": "^2.5.7",
|
|
36
|
-
"svelte": "^5.
|
|
36
|
+
"svelte": "^5.50.0",
|
|
37
37
|
"typescript": "^5.9.3"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@mochabug/adapt-web": "^1.0.0-
|
|
40
|
+
"@mochabug/adapt-web": "^1.0.0-rc39"
|
|
41
41
|
}
|
|
42
42
|
}
|