@mochabug/adapt-vue 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/esm/AdaptCap.js +122 -0
- package/dist/esm/index.js +20 -0
- package/dist/types/AdaptCap.d.ts +102 -0
- package/dist/types/index.d.ts +37 -3
- package/package.json +2 -2
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AdaptCapWidget } from "@mochabug/adapt-web";
|
|
2
|
+
import { defineComponent, h, onMounted, onUnmounted, ref, watch, } from "vue";
|
|
3
|
+
// Re-export for direct use
|
|
4
|
+
export { AdaptCapWidget, } from "@mochabug/adapt-web";
|
|
5
|
+
/**
|
|
6
|
+
* Vue component for Cap.js proof-of-work challenges.
|
|
7
|
+
*
|
|
8
|
+
* Use this component independently of the Adapt iframe component
|
|
9
|
+
* to solve PoW challenges and get a token for starting sessions.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```vue
|
|
13
|
+
* <template>
|
|
14
|
+
* <AdaptCap
|
|
15
|
+
* :automation-id="automationId"
|
|
16
|
+
* :client="rawClient"
|
|
17
|
+
* @solve="handleSolve"
|
|
18
|
+
* />
|
|
19
|
+
* </template>
|
|
20
|
+
*
|
|
21
|
+
* <script setup>
|
|
22
|
+
* import { AdaptCap } from "@mochabug/adapt-vue";
|
|
23
|
+
* import { createConnectClient } from "@mochabug/adapt-core/connect";
|
|
24
|
+
*
|
|
25
|
+
* const automationId = "my-automation";
|
|
26
|
+
* const rawClient = createConnectClient({ id: automationId });
|
|
27
|
+
*
|
|
28
|
+
* async function handleSolve(token, expires) {
|
|
29
|
+
* const client = createAdaptClient(rawClient, automationId);
|
|
30
|
+
* await client.run({ challengeToken: token });
|
|
31
|
+
* }
|
|
32
|
+
* </script>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const AdaptCap = defineComponent({
|
|
36
|
+
name: "AdaptCap",
|
|
37
|
+
inheritAttrs: false,
|
|
38
|
+
props: {
|
|
39
|
+
/** Automation ID for challenge endpoints */
|
|
40
|
+
automationId: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: true,
|
|
43
|
+
},
|
|
44
|
+
/** The raw automation client for API calls */
|
|
45
|
+
client: {
|
|
46
|
+
type: Object,
|
|
47
|
+
required: true,
|
|
48
|
+
},
|
|
49
|
+
/** Number of workers for Cap.js */
|
|
50
|
+
workerCount: {
|
|
51
|
+
type: Number,
|
|
52
|
+
default: undefined,
|
|
53
|
+
},
|
|
54
|
+
/** Custom labels for Cap.js widget */
|
|
55
|
+
i18n: {
|
|
56
|
+
type: Object,
|
|
57
|
+
default: undefined,
|
|
58
|
+
},
|
|
59
|
+
/** Enable dark mode styling */
|
|
60
|
+
darkMode: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
emits: {
|
|
66
|
+
/** Emitted when challenge is solved */
|
|
67
|
+
solve: (_token, _expires) => true,
|
|
68
|
+
/** Emitted on error */
|
|
69
|
+
error: (_error) => true,
|
|
70
|
+
},
|
|
71
|
+
setup(props, { emit, attrs }) {
|
|
72
|
+
const containerRef = ref(null);
|
|
73
|
+
let widget = null;
|
|
74
|
+
const createWidget = () => {
|
|
75
|
+
if (!containerRef.value)
|
|
76
|
+
return;
|
|
77
|
+
if (widget) {
|
|
78
|
+
widget.destroy();
|
|
79
|
+
widget = null;
|
|
80
|
+
}
|
|
81
|
+
widget = new AdaptCapWidget({
|
|
82
|
+
container: containerRef.value,
|
|
83
|
+
automationId: props.automationId,
|
|
84
|
+
client: props.client,
|
|
85
|
+
onSolve: (token, expires) => {
|
|
86
|
+
emit("solve", token, expires);
|
|
87
|
+
},
|
|
88
|
+
onError: (error) => {
|
|
89
|
+
emit("error", error);
|
|
90
|
+
},
|
|
91
|
+
...(props.workerCount !== undefined && {
|
|
92
|
+
workerCount: props.workerCount,
|
|
93
|
+
}),
|
|
94
|
+
...(props.i18n !== undefined && { i18n: props.i18n }),
|
|
95
|
+
});
|
|
96
|
+
if (props.darkMode) {
|
|
97
|
+
widget.setDarkMode(true);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
onMounted(() => {
|
|
101
|
+
createWidget();
|
|
102
|
+
});
|
|
103
|
+
onUnmounted(() => {
|
|
104
|
+
if (widget) {
|
|
105
|
+
widget.destroy();
|
|
106
|
+
widget = null;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
// Recreate widget if automation ID or client changes
|
|
110
|
+
watch(() => props.automationId, createWidget);
|
|
111
|
+
watch(() => props.client, createWidget);
|
|
112
|
+
// Update dark mode
|
|
113
|
+
watch(() => props.darkMode, (value) => {
|
|
114
|
+
widget?.setDarkMode(value);
|
|
115
|
+
});
|
|
116
|
+
return () => h("div", {
|
|
117
|
+
ref: containerRef,
|
|
118
|
+
...attrs,
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
export default AdaptCap;
|
package/dist/esm/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import { AdaptWebClient, } from "@mochabug/adapt-web";
|
|
|
2
2
|
import { defineComponent, h, onMounted, onUnmounted, ref, watch, } from "vue";
|
|
3
3
|
// Re-export everything from web
|
|
4
4
|
export * from "@mochabug/adapt-web";
|
|
5
|
+
// Export standalone Cap widget component
|
|
6
|
+
export { AdaptCap } from "./AdaptCap.js";
|
|
5
7
|
/**
|
|
6
8
|
* Vue component for embedding Adapt automations.
|
|
7
9
|
*/
|
|
@@ -74,6 +76,21 @@ export const Adapt = defineComponent({
|
|
|
74
76
|
type: Object,
|
|
75
77
|
default: undefined,
|
|
76
78
|
},
|
|
79
|
+
/** Pre-solved challenge token for PoW-protected automations */
|
|
80
|
+
challengeToken: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: undefined,
|
|
83
|
+
},
|
|
84
|
+
/** Show Cap.js widget before starting (for PoW-protected automations) */
|
|
85
|
+
requiresChallenge: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
89
|
+
/** Options for customizing Cap.js widget */
|
|
90
|
+
capWidgetOptions: {
|
|
91
|
+
type: Object,
|
|
92
|
+
default: undefined,
|
|
93
|
+
},
|
|
77
94
|
},
|
|
78
95
|
emits: {
|
|
79
96
|
/** Emitted when session status changes */
|
|
@@ -96,6 +113,9 @@ export const Adapt = defineComponent({
|
|
|
96
113
|
authToken: props.authToken,
|
|
97
114
|
transmitter: props.transmitter,
|
|
98
115
|
signals: props.signals,
|
|
116
|
+
challengeToken: props.challengeToken,
|
|
117
|
+
requiresChallenge: props.requiresChallenge,
|
|
118
|
+
capWidgetOptions: props.capWidgetOptions,
|
|
99
119
|
inheritToken: props.inheritToken,
|
|
100
120
|
inheritFrom: props.inheritFrom,
|
|
101
121
|
forkDisplayMode: props.forkDisplayMode,
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { AutomationClient } from "@mochabug/adapt-core";
|
|
2
|
+
import { type CapWidgetI18n } from "@mochabug/adapt-web";
|
|
3
|
+
import { type PropType } from "vue";
|
|
4
|
+
export { AdaptCapWidget, type AdaptCapWidgetOptions, } from "@mochabug/adapt-web";
|
|
5
|
+
/**
|
|
6
|
+
* Vue component for Cap.js proof-of-work challenges.
|
|
7
|
+
*
|
|
8
|
+
* Use this component independently of the Adapt iframe component
|
|
9
|
+
* to solve PoW challenges and get a token for starting sessions.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```vue
|
|
13
|
+
* <template>
|
|
14
|
+
* <AdaptCap
|
|
15
|
+
* :automation-id="automationId"
|
|
16
|
+
* :client="rawClient"
|
|
17
|
+
* @solve="handleSolve"
|
|
18
|
+
* />
|
|
19
|
+
* </template>
|
|
20
|
+
*
|
|
21
|
+
* <script setup>
|
|
22
|
+
* import { AdaptCap } from "@mochabug/adapt-vue";
|
|
23
|
+
* import { createConnectClient } from "@mochabug/adapt-core/connect";
|
|
24
|
+
*
|
|
25
|
+
* const automationId = "my-automation";
|
|
26
|
+
* const rawClient = createConnectClient({ id: automationId });
|
|
27
|
+
*
|
|
28
|
+
* async function handleSolve(token, expires) {
|
|
29
|
+
* const client = createAdaptClient(rawClient, automationId);
|
|
30
|
+
* await client.run({ challengeToken: token });
|
|
31
|
+
* }
|
|
32
|
+
* </script>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const AdaptCap: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
36
|
+
/** Automation ID for challenge endpoints */
|
|
37
|
+
automationId: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
required: true;
|
|
40
|
+
};
|
|
41
|
+
/** The raw automation client for API calls */
|
|
42
|
+
client: {
|
|
43
|
+
type: PropType<AutomationClient>;
|
|
44
|
+
required: true;
|
|
45
|
+
};
|
|
46
|
+
/** Number of workers for Cap.js */
|
|
47
|
+
workerCount: {
|
|
48
|
+
type: NumberConstructor;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
/** Custom labels for Cap.js widget */
|
|
52
|
+
i18n: {
|
|
53
|
+
type: PropType<CapWidgetI18n>;
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
56
|
+
/** Enable dark mode styling */
|
|
57
|
+
darkMode: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
default: boolean;
|
|
60
|
+
};
|
|
61
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
64
|
+
/** Emitted when challenge is solved */
|
|
65
|
+
solve: (_token: string, _expires: Date) => true;
|
|
66
|
+
/** Emitted on error */
|
|
67
|
+
error: (_error: Error) => true;
|
|
68
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
69
|
+
/** Automation ID for challenge endpoints */
|
|
70
|
+
automationId: {
|
|
71
|
+
type: StringConstructor;
|
|
72
|
+
required: true;
|
|
73
|
+
};
|
|
74
|
+
/** The raw automation client for API calls */
|
|
75
|
+
client: {
|
|
76
|
+
type: PropType<AutomationClient>;
|
|
77
|
+
required: true;
|
|
78
|
+
};
|
|
79
|
+
/** Number of workers for Cap.js */
|
|
80
|
+
workerCount: {
|
|
81
|
+
type: NumberConstructor;
|
|
82
|
+
default: undefined;
|
|
83
|
+
};
|
|
84
|
+
/** Custom labels for Cap.js widget */
|
|
85
|
+
i18n: {
|
|
86
|
+
type: PropType<CapWidgetI18n>;
|
|
87
|
+
default: undefined;
|
|
88
|
+
};
|
|
89
|
+
/** Enable dark mode styling */
|
|
90
|
+
darkMode: {
|
|
91
|
+
type: BooleanConstructor;
|
|
92
|
+
default: boolean;
|
|
93
|
+
};
|
|
94
|
+
}>> & Readonly<{
|
|
95
|
+
onSolve?: ((_token: string, _expires: Date) => any) | undefined;
|
|
96
|
+
onError?: ((_error: Error) => any) | undefined;
|
|
97
|
+
}>, {
|
|
98
|
+
workerCount: number;
|
|
99
|
+
i18n: CapWidgetI18n;
|
|
100
|
+
darkMode: boolean;
|
|
101
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
102
|
+
export default AdaptCap;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AdaptWebClientOptions, type Output, type SignalValue, type StatusJson } from "@mochabug/adapt-web";
|
|
2
2
|
import { type PropType } from "vue";
|
|
3
3
|
export * from "@mochabug/adapt-web";
|
|
4
|
+
export { AdaptCap } from "./AdaptCap.js";
|
|
4
5
|
/**
|
|
5
6
|
* Vue component for embedding Adapt automations.
|
|
6
7
|
*/
|
|
@@ -76,6 +77,21 @@ export declare const Adapt: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
76
77
|
type: PropType<AdaptWebClientOptions["classNames"]>;
|
|
77
78
|
default: undefined;
|
|
78
79
|
};
|
|
80
|
+
/** Pre-solved challenge token for PoW-protected automations */
|
|
81
|
+
challengeToken: {
|
|
82
|
+
type: StringConstructor;
|
|
83
|
+
default: undefined;
|
|
84
|
+
};
|
|
85
|
+
/** Show Cap.js widget before starting (for PoW-protected automations) */
|
|
86
|
+
requiresChallenge: {
|
|
87
|
+
type: BooleanConstructor;
|
|
88
|
+
default: boolean;
|
|
89
|
+
};
|
|
90
|
+
/** Options for customizing Cap.js widget */
|
|
91
|
+
capWidgetOptions: {
|
|
92
|
+
type: PropType<AdaptWebClientOptions["capWidgetOptions"]>;
|
|
93
|
+
default: undefined;
|
|
94
|
+
};
|
|
79
95
|
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
80
96
|
[key: string]: any;
|
|
81
97
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
@@ -155,10 +171,26 @@ export declare const Adapt: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
155
171
|
type: PropType<AdaptWebClientOptions["classNames"]>;
|
|
156
172
|
default: undefined;
|
|
157
173
|
};
|
|
174
|
+
/** Pre-solved challenge token for PoW-protected automations */
|
|
175
|
+
challengeToken: {
|
|
176
|
+
type: StringConstructor;
|
|
177
|
+
default: undefined;
|
|
178
|
+
};
|
|
179
|
+
/** Show Cap.js widget before starting (for PoW-protected automations) */
|
|
180
|
+
requiresChallenge: {
|
|
181
|
+
type: BooleanConstructor;
|
|
182
|
+
default: boolean;
|
|
183
|
+
};
|
|
184
|
+
/** Options for customizing Cap.js widget */
|
|
185
|
+
capWidgetOptions: {
|
|
186
|
+
type: PropType<AdaptWebClientOptions["capWidgetOptions"]>;
|
|
187
|
+
default: undefined;
|
|
188
|
+
};
|
|
158
189
|
}>> & Readonly<{
|
|
159
|
-
onSession?: ((_status: StatusJson, _fork?: string | undefined) => any) | undefined;
|
|
160
190
|
onOutput?: ((_output: Output) => any) | undefined;
|
|
191
|
+
onSession?: ((_status: StatusJson, _fork?: string | undefined) => any) | undefined;
|
|
161
192
|
}>, {
|
|
193
|
+
darkMode: boolean;
|
|
162
194
|
classNames: {
|
|
163
195
|
root?: string;
|
|
164
196
|
wrapper?: string;
|
|
@@ -173,6 +205,7 @@ export declare const Adapt: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
173
205
|
dragHandle?: string;
|
|
174
206
|
expandButton?: string;
|
|
175
207
|
} | undefined;
|
|
208
|
+
capWidgetOptions: import("@mochabug/adapt-web").CapWidgetOptions | undefined;
|
|
176
209
|
sessionToken: string;
|
|
177
210
|
authToken: string;
|
|
178
211
|
transmitter: string;
|
|
@@ -185,10 +218,11 @@ export declare const Adapt: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
185
218
|
} | {
|
|
186
219
|
param: string;
|
|
187
220
|
};
|
|
188
|
-
forkDisplayMode: "side-by-side"
|
|
221
|
+
forkDisplayMode: "dialog" | "side-by-side";
|
|
189
222
|
sideBySideSplit: number;
|
|
190
223
|
dialogBackdropClose: boolean;
|
|
191
|
-
darkMode: boolean;
|
|
192
224
|
autoResizing: boolean;
|
|
225
|
+
challengeToken: string;
|
|
226
|
+
requiresChallenge: boolean;
|
|
193
227
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
194
228
|
export default Adapt;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mochabug/adapt-vue",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc15",
|
|
4
4
|
"description": "Vue component for Adapt automation platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"vue": "^3.5.26"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@mochabug/adapt-web": "^1.0.0-
|
|
39
|
+
"@mochabug/adapt-web": "^1.0.0-rc37"
|
|
40
40
|
}
|
|
41
41
|
}
|