Commit Graph

41 Commits

Author SHA1 Message Date
Taras Kushnir
cab8ae71e2 Fix widget reset code 2026-01-20 11:13:10 +02:00
Taras Kushnir
cd536f5393 Make progress component safer 2026-01-17 09:19:59 +02:00
Taras Kushnir
808f979ae0 Fix widget thickness 2026-01-16 19:12:10 +02:00
Taras Kushnir
0ceb759fee Refactor html string concatenation to JS in widget html
credit to Claude Opus 4.5 w/ GH copilot
2026-01-14 18:56:47 +02:00
Taras Kushnir
ec0aca8b7f Cosmetic improvement 2026-01-14 10:15:25 +02:00
Taras Kushnir
28ba7ed860 Create html element explicitly 2026-01-14 10:12:59 +02:00
Taras Kushnir
ba1dcb1492 Cosmetic improvements 2026-01-13 21:29:17 +02:00
Taras Kushnir
411a289e32 Protect against private-captcha redeclaration 2026-01-13 21:23:11 +02:00
Luke Watts
2a1e074b17 fix: guard against custom element 'progress-ring' already existing (#250)
When the widget script is loaded multiple times (possible in SPA environments with framework component lifecycles), the application crashes with:

```
Uncaught DOMException: CustomElementRegistry.define: 'progress-ring' has already been defined as a custom element
```

This occurs because `customElements.define()` throws an error if called twice with the same element name, and the Custom Elements API provides no way to undefine or replace registered elements.

### Solution
Added a guard to check if the custom element is already registered before attempting to define it:
```javascript
if (typeof window !== "undefined" && 
    window.customElements && 
    !window.customElements.get('progress-ring')) {
    window.customElements.define('progress-ring', ProgressRing);
}
```

### Why This Matters
- **Prevents crashes** in SPA environments where components mount/unmount repeatedly
- **Idempotent behavior** - script can safely be included multiple times

This is a defensive programming practice recommended for any third-party script that registers custom elements, as you cannot control how integrators will load your code.
2026-01-13 21:19:49 +02:00
Taras Kushnir
a25fd054c8 Cosmetic improvements 2025-12-19 13:19:04 +01:00
Taras Kushnir
3f6856698d Bump widget attempts 2025-12-19 12:22:43 +01:00
Taras Kushnir
2fe3fe6105 Cosmetic improvements
found by GitHub code quality
2025-12-15 15:49:57 +01:00
Taras Kushnir
cc94c898cd Skip duplicate user started and execute triggers 2025-11-29 13:49:57 +01:00
Taras Kushnir
7a921f8858 Fix auto-start mode in popup widget mode 2025-11-29 13:06:49 +01:00
Taras Kushnir
6533940c1e Add explicit reset method to workers pool 2025-10-21 09:00:08 +03:00
Taras Kushnir
16305e2ff1 Do not remove onFocusIn event handler 2025-10-21 08:59:42 +03:00
Taras Kushnir
794b6200b3 Cosmetic JS improvements 2025-10-21 08:58:34 +03:00
Taras Kushnir
d0355faae0 Add auto mode for widget language 2025-10-21 08:57:03 +03:00
Taras Kushnir
21df85eb70 Fix issues with widget
- calling widget.reset() on page load cased the visualization to start on it's own
- focusin (if fired) was cleared from handlers - now we re-add it in reset()
2025-10-20 21:26:53 +03:00
Taras Kushnir
350868dbd3 Save solution only when user clicks widget. closes PrivateCaptcha/issues#202 2025-10-18 11:27:04 +03:00
Taras Kushnir
1fc4440f83 Verify styles changed before updating them 2025-10-12 13:10:35 +03:00
Taras Kushnir
365f253b27 Fix immutable stylesheet error when updating widget styles 2025-10-12 13:08:10 +03:00
Taras Kushnir
6ae42a8b60 Add feature to widget to update data-styles 2025-10-11 21:40:45 +03:00
Taras Kushnir
698ca5c78d Add more event tests to widget 2025-10-11 09:49:26 +03:00
Taras Kushnir
fe1b40b99d Add widget test
Mainly for bug fixed in 5df983a5c4
2025-10-10 16:09:12 +03:00
Taras Kushnir
5df983a5c4 Fix invisible widget 2025-10-10 12:04:42 +03:00
Taras Kushnir
10e6d6092a Revert "Force widget font size override for external styles interference"
This reverts commit f430c84d4a.
2025-10-10 09:20:37 +03:00
Taras Kushnir
f430c84d4a Force widget font size override for external styles interference 2025-10-10 09:09:00 +03:00
Taras Kushnir
f9d3524a37 Rephrase widget js error message 2025-10-10 08:56:39 +03:00
Taras Kushnir
c3335d3405 Make widget color configurable 2025-09-26 16:50:32 +03:00
Taras Kushnir
909f31a71a Restore default widget start mode to auto 2025-09-24 09:07:40 +03:00
Taras Kushnir
8151214cb5 Use events instead of JS callbacks 2025-09-03 11:44:18 +03:00
Taras Kushnir
1e9a00f8c9 Add widget strings translations to few European languages
Bump widget lib version
2025-08-16 11:17:41 +03:00
Taras Kushnir
a6be38e0be Add site script compatibility mode with Google reCAPTCHA 2025-08-11 12:38:05 +03:00
Taras Kushnir
26d3c2bd31 Vibe-code few TS annotations for widget code 2025-07-15 18:12:48 +03:00
Taras Kushnir
d6440d7d8b Cosmetic improvements 2025-06-29 13:49:33 +03:00
Taras Kushnir
a8d848c070 Fix usage of widget library as a package 2025-06-29 13:21:10 +03:00
Taras Kushnir
d3e69dc75c Cosmetic improvements
Typical SonarCloud spam
2025-06-24 19:08:55 +03:00
Taras Kushnir
247a5aa468 Add JS callbacks to widget options 2025-06-23 16:07:21 +03:00
Taras Kushnir
30417742f9 Add nofollow rel attribute to widget link 2025-06-16 16:17:21 +03:00
Taras Kushnir
4951055189 Initial commit 2025-05-31 10:56:00 +03:00