@mochabug/adapt-svelte 1.0.0-rc12 → 1.0.0-rc15

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 CHANGED
@@ -9,6 +9,9 @@
9
9
  authToken?: string;
10
10
  transmitter?: string;
11
11
  signals?: { [key: string]: SignalValue };
12
+ challengeToken?: string;
13
+ requiresChallenge?: boolean;
14
+ capWidgetOptions?: AdaptWebClientOptions['capWidgetOptions'];
12
15
  inheritToken?: string;
13
16
  inheritFrom?: { hash: string } | { param: string };
14
17
  forkDisplayMode?: 'side-by-side' | 'dialog';
@@ -28,6 +31,9 @@
28
31
  authToken = undefined,
29
32
  transmitter = undefined,
30
33
  signals = undefined,
34
+ challengeToken = undefined,
35
+ requiresChallenge = false,
36
+ capWidgetOptions = undefined,
31
37
  inheritToken = undefined,
32
38
  inheritFrom = undefined,
33
39
  forkDisplayMode = 'side-by-side',
@@ -57,6 +63,9 @@
57
63
  authToken,
58
64
  transmitter,
59
65
  signals,
66
+ challengeToken,
67
+ requiresChallenge,
68
+ capWidgetOptions,
60
69
  inheritToken,
61
70
  inheritFrom,
62
71
  forkDisplayMode,
@@ -7,6 +7,9 @@ interface Props {
7
7
  signals?: {
8
8
  [key: string]: SignalValue;
9
9
  };
10
+ challengeToken?: string;
11
+ requiresChallenge?: boolean;
12
+ capWidgetOptions?: AdaptWebClientOptions['capWidgetOptions'];
10
13
  inheritToken?: string;
11
14
  inheritFrom?: {
12
15
  hash: string;
@@ -0,0 +1,83 @@
1
+ <script lang="ts">
2
+ import type { AutomationClient } from '@mochabug/adapt-core';
3
+ import { AdaptCapWidget, type CapWidgetI18n } from '@mochabug/adapt-web';
4
+ import { onDestroy, onMount } from 'svelte';
5
+
6
+ // Props interface
7
+ interface Props {
8
+ automationId: string;
9
+ client: AutomationClient;
10
+ workerCount?: number;
11
+ i18n?: CapWidgetI18n;
12
+ darkMode?: boolean;
13
+ onsolve?: (event: { token: string; expires: Date }) => void;
14
+ onerror?: (event: { error: Error }) => void;
15
+ [key: string]: unknown;
16
+ }
17
+
18
+ let {
19
+ automationId,
20
+ client,
21
+ workerCount = undefined,
22
+ i18n = undefined,
23
+ darkMode = false,
24
+ onsolve,
25
+ onerror,
26
+ ...restProps
27
+ }: Props = $props();
28
+
29
+ let container: HTMLElement;
30
+ let widget: AdaptCapWidget | null = null;
31
+
32
+ function createWidget() {
33
+ if (!container || !client) return;
34
+
35
+ if (widget) {
36
+ widget.destroy();
37
+ widget = null;
38
+ }
39
+
40
+ widget = new AdaptCapWidget({
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
+ }
57
+ }
58
+
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
+ $effect(() => {
79
+ widget?.setDarkMode(darkMode);
80
+ });
81
+ </script>
82
+
83
+ <div bind:this={container} {...restProps}></div>
@@ -0,0 +1,20 @@
1
+ import type { AutomationClient } from '@mochabug/adapt-core';
2
+ import { type CapWidgetI18n } from '@mochabug/adapt-web';
3
+ interface Props {
4
+ automationId: string;
5
+ client: AutomationClient;
6
+ workerCount?: number;
7
+ i18n?: CapWidgetI18n;
8
+ darkMode?: boolean;
9
+ onsolve?: (event: {
10
+ token: string;
11
+ expires: Date;
12
+ }) => void;
13
+ onerror?: (event: {
14
+ error: Error;
15
+ }) => void;
16
+ [key: string]: unknown;
17
+ }
18
+ declare const AdaptCap: import("svelte").Component<Props, {}, "">;
19
+ type AdaptCap = ReturnType<typeof AdaptCap>;
20
+ export default AdaptCap;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "@mochabug/adapt-web";
2
2
  export { default as Adapt } from "./Adapt.svelte";
3
+ export { default as AdaptCap } from "./AdaptCap.svelte";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  // Re-export everything from web
2
2
  export * from "@mochabug/adapt-web";
3
3
  export { default as Adapt } from "./Adapt.svelte";
4
+ export { default as AdaptCap } from "./AdaptCap.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mochabug/adapt-svelte",
3
- "version": "1.0.0-rc12",
3
+ "version": "1.0.0-rc15",
4
4
  "description": "Svelte component for Adapt automation platform",
5
5
  "type": "module",
6
6
  "svelte": "./dist/index.js",
@@ -37,6 +37,6 @@
37
37
  "typescript": "^5.9.3"
38
38
  },
39
39
  "dependencies": {
40
- "@mochabug/adapt-web": "^1.0.0-rc34"
40
+ "@mochabug/adapt-web": "^1.0.0-rc37"
41
41
  }
42
42
  }