trustcaptcha-svelte 0.0.5 → 0.0.8
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/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/captcha.svelte +41 -30
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Frederic Lehmann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# TrustCaptcha for Svelte
|
|
2
2
|
|
|
3
|
+
> **Note:** This is a community integration, not officially maintained by TrustCaptcha.
|
|
4
|
+
|
|
3
5
|
A Svelte 5 component for integrating [TrustCaptcha](https://www.trustcomponent.com/) CAPTCHA widget into your Svelte applications.
|
|
4
6
|
|
|
5
7
|
## Features
|
package/dist/captcha.svelte
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
2
3
|
import type { TrustCaptchaProps } from './index.js';
|
|
3
4
|
|
|
4
5
|
let {
|
|
@@ -19,9 +20,8 @@
|
|
|
19
20
|
}: TrustCaptchaProps = $props();
|
|
20
21
|
|
|
21
22
|
let captchaElement: HTMLElement | null = $state(null);
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
);
|
|
23
|
+
let mounted = $state(false);
|
|
24
|
+
let scriptLoaded = $state(false);
|
|
25
25
|
|
|
26
26
|
const customTranslationsStr = $derived(
|
|
27
27
|
typeof customTranslations === 'object' ? JSON.stringify(customTranslations) : customTranslations
|
|
@@ -31,12 +31,31 @@
|
|
|
31
31
|
typeof customDesign === 'object' ? JSON.stringify(customDesign) : customDesign
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
onMount(() => {
|
|
35
|
+
mounted = true;
|
|
36
|
+
|
|
37
|
+
if (typeof customElements !== 'undefined' && customElements.get('trustcaptcha-component')) {
|
|
38
|
+
scriptLoaded = true;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const script = document.createElement('script');
|
|
43
|
+
script.type = 'module';
|
|
44
|
+
script.src = 'https://cdn.trustcomponent.com/trustcaptcha/2.1.x/trustcaptcha.esm.min.js';
|
|
45
|
+
script.onload = () => {
|
|
46
|
+
scriptLoaded = true;
|
|
47
|
+
};
|
|
48
|
+
document.head.appendChild(script);
|
|
49
|
+
|
|
50
|
+
return () => {
|
|
51
|
+
if (script.parentNode) {
|
|
52
|
+
script.parentNode.removeChild(script);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
});
|
|
37
56
|
|
|
38
57
|
$effect(() => {
|
|
39
|
-
if (!captchaElement || !scriptLoaded) return;
|
|
58
|
+
if (!captchaElement || !scriptLoaded || !mounted) return;
|
|
40
59
|
|
|
41
60
|
const handlers: Record<string, EventListener | undefined> = {
|
|
42
61
|
captchaStarted: oncaptchaStarted as EventListener | undefined,
|
|
@@ -69,26 +88,18 @@
|
|
|
69
88
|
}
|
|
70
89
|
</script>
|
|
71
90
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
invisible-hint={invisibleHint}
|
|
88
|
-
bypass-token={bypassToken}
|
|
89
|
-
token-field-name={tokenFieldName}
|
|
90
|
-
custom-translations={customTranslationsStr}
|
|
91
|
-
custom-design={customDesignStr}
|
|
92
|
-
privacy-url={privacyUrl}
|
|
93
|
-
{...rest}
|
|
94
|
-
></trustcaptcha-component>
|
|
91
|
+
{#if mounted && scriptLoaded}
|
|
92
|
+
<trustcaptcha-component
|
|
93
|
+
bind:this={captchaElement}
|
|
94
|
+
autostart={autostart ? undefined : 'false'}
|
|
95
|
+
hide-branding={hideBranding ? 'true' : undefined}
|
|
96
|
+
invisible={invisible ? 'true' : undefined}
|
|
97
|
+
invisible-hint={invisibleHint}
|
|
98
|
+
bypass-token={bypassToken}
|
|
99
|
+
token-field-name={tokenFieldName}
|
|
100
|
+
custom-translations={customTranslationsStr}
|
|
101
|
+
custom-design={customDesignStr}
|
|
102
|
+
privacy-url={privacyUrl}
|
|
103
|
+
{...rest}
|
|
104
|
+
></trustcaptcha-component>
|
|
105
|
+
{/if}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trustcaptcha-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A Svelte 5 component for integrating TrustCaptcha CAPTCHA widget into your Svelte applications",
|
|
6
6
|
"author": "Frederic Lehmann",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"prettier": "^3.8.1",
|
|
50
50
|
"prettier-plugin-svelte": "^3.4.1",
|
|
51
51
|
"publint": "^0.3.17",
|
|
52
|
-
"svelte": "^5.48.
|
|
52
|
+
"svelte": "^5.48.3",
|
|
53
53
|
"svelte-check": "^4.3.5",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
|
-
"typescript-eslint": "^8.
|
|
55
|
+
"typescript-eslint": "^8.54.0",
|
|
56
56
|
"vite": "^7.3.1",
|
|
57
57
|
"vitest": "^4.0.18",
|
|
58
58
|
"vitest-browser-svelte": "^2.0.2"
|