@prosopo/procaptcha-bundle 4.1.49 → 4.1.50

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @prosopo/procaptcha-bundle@4.1.49 build:cjs
2
+ > @prosopo/procaptcha-bundle@4.1.50 build:cjs
3
3
  > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
4
4
 
5
5
  ViteCommonJSConfig: .
@@ -29,7 +29,6 @@ ViteCommonJSConfig: .
29
29
  ]
30
30
  }
31
31
  {
32
- The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
33
32
  externals: [
34
33
  '@prosopo/dotenv',
35
34
  '@prosopo/logger',
@@ -54,6 +53,7 @@ ViteCommonJSConfig: .
54
53
  '@prosopo/datasets'
55
54
  ]
56
55
  }
56
+ The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
57
57
  vite v8.1.5 building ssr environment for production...
58
58
  Bundle build started
59
59
  
@@ -69,8 +69,8 @@ dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
69
69
  dist/cjs/util/language.cjs 1.08 kB │ gzip: 0.45 kB
70
70
  dist/cjs/util/captcha/captchaRenderer.cjs 2.26 kB │ gzip: 0.78 kB
71
71
  dist/cjs/util/widgetFactory.cjs 2.73 kB │ gzip: 0.89 kB
72
- dist/cjs/index.cjs 6.42 kB │ gzip: 2.14 kB
72
+ dist/cjs/index.cjs 9.20 kB │ gzip: 3.22 kB
73
73
 
74
- [MIXED_EXPORTS] Entry module "src/index.ts" is using named (including "default", "execute", "render", "reset") and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
74
+ [MIXED_EXPORTS] Entry module "src/index.ts" is using named (including "default", "execute", "remove", "render", "reset") and default exports together. Consumers of your bundle will have to use `..default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
75
75
  
76
- ✓ built in 64ms
76
+ ✓ built in 50ms
@@ -1,8 +1,8 @@
1
1
 
2
- > @prosopo/procaptcha-bundle@4.1.49 build:tsc
2
+ > @prosopo/procaptcha-bundle@4.1.50 build:tsc
3
3
  > tsc --build --verbose
4
4
 
5
- 7:05:50 AM - Projects in this build:
5
+ 3:31:51 PM - Projects in this build:
6
6
  * ../../dev/config/tsconfig.json
7
7
  * ../util/tsconfig.json
8
8
  * ../logger/tsconfig.json
@@ -27,51 +27,51 @@
27
27
  * ../procaptcha-frictionless/tsconfig.json
28
28
  * tsconfig.json
29
29
 
30
- 7:05:50 AM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/vite/vite-plugin-copy.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
30
+ 3:31:52 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
31
31
 
32
- 7:05:50 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
32
+ 3:31:52 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
33
33
 
34
- 7:05:50 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
34
+ 3:31:52 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/tsconfig.tsbuildinfo'
35
35
 
36
- 7:05:50 AM - Project '../dotenv/tsconfig.json' is up to date because newest input '../dotenv/src/env.ts' is older than output '../dotenv/tsconfig.tsbuildinfo'
36
+ 3:31:52 PM - Project '../dotenv/tsconfig.json' is up to date because newest input '../dotenv/src/env.ts' is older than output '../dotenv/tsconfig.tsbuildinfo'
37
37
 
38
- 7:05:50 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
38
+ 3:31:52 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
39
39
 
40
- 7:05:50 AM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
40
+ 3:31:52 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
41
41
 
42
- 7:05:50 AM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
42
+ 3:31:52 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
43
43
 
44
- 7:05:50 AM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/tests/api.test-d.ts' is older than output '../api/tsconfig.tsbuildinfo'
44
+ 3:31:52 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
45
45
 
46
- 7:05:50 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
46
+ 3:31:52 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
47
47
 
48
- 7:05:50 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/sources/webgl.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
48
+ 3:31:52 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
49
49
 
50
- 7:05:50 AM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
50
+ 3:31:52 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
51
51
 
52
- 7:05:50 AM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/balancer.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
52
+ 3:31:52 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/balancer.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
53
53
 
54
- 7:05:50 AM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/webComponent/createWebComponent.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
54
+ 3:31:52 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/webComponent/createWidget.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
55
55
 
56
- 7:05:50 AM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/index.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
56
+ 3:31:52 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/keyring/keyring.test.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
57
57
 
58
- 7:05:50 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/index.ts' is older than output '../account/tsconfig.tsbuildinfo'
58
+ 3:31:52 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/workers/cryptoWorker.ts' is older than output '../account/tsconfig.tsbuildinfo'
59
59
 
60
- 7:05:51 AM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/simdReadings.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
60
+ 3:31:52 PM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/defaultEvents.test.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
61
61
 
62
- 7:05:51 AM - Project '../procaptcha-pow/tsconfig.json' is up to date because newest input '../procaptcha-pow/src/tests/managerHarness.ts' is older than output '../procaptcha-pow/tsconfig.tsbuildinfo'
62
+ 3:31:52 PM - Project '../procaptcha-pow/tsconfig.json' is up to date because newest input '../procaptcha-pow/src/index.ts' is older than output '../procaptcha-pow/tsconfig.tsbuildinfo'
63
63
 
64
- 7:05:51 AM - Project '../procaptcha-puzzle/tsconfig.json' is up to date because newest input '../procaptcha-puzzle/src/tests/manager.unit.test.ts' is older than output '../procaptcha-puzzle/tsconfig.tsbuildinfo'
64
+ 3:31:52 PM - Project '../procaptcha-puzzle/tsconfig.json' is up to date because newest input '../procaptcha-puzzle/src/tests/managerHarness.ts' is older than output '../procaptcha-puzzle/tsconfig.tsbuildinfo'
65
65
 
66
- 7:05:51 AM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
66
+ 3:31:52 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/tests/dataset.unit.test.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
67
67
 
68
- 7:05:51 AM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/tests/manager.unit.test.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
68
+ 3:31:52 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/tests/manager.unit.test.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
69
69
 
70
- 7:05:51 AM - Project '../procaptcha-react/tsconfig.json' is up to date because newest input '../procaptcha-react/src/index.ts' is older than output '../procaptcha-react/tsconfig.tsbuildinfo'
70
+ 3:31:52 PM - Project '../procaptcha-react/tsconfig.json' is up to date because newest input '../procaptcha-react/src/index.ts' is older than output '../procaptcha-react/tsconfig.tsbuildinfo'
71
71
 
72
- 7:05:51 AM - Project '../procaptcha-frictionless/tsconfig.json' is up to date because newest input '../procaptcha-frictionless/src/ProcaptchaFrictionless.tsx' is older than output '../procaptcha-frictionless/tsconfig.tsbuildinfo'
72
+ 3:31:52 PM - Project '../procaptcha-frictionless/tsconfig.json' is up to date because newest input '../procaptcha-frictionless/src/customDetectBot.ts' is older than output '../procaptcha-frictionless/tsconfig.tsbuildinfo'
73
73
 
74
- 7:05:51 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
74
+ 3:31:52 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
75
75
 
76
- 7:05:51 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-bundle/tsconfig.json'...
76
+ 3:31:52 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-bundle/tsconfig.json'...
77
77
 
@@ -1,9 +1,9 @@
1
1
 
2
- > @prosopo/procaptcha-bundle@4.1.49 build
2
+ > @prosopo/procaptcha-bundle@4.1.50 build
3
3
  > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
4
 
5
5
 
6
- > @prosopo/procaptcha-bundle@4.1.49 build:cross-env
6
+ > @prosopo/procaptcha-bundle@4.1.50 build:cross-env
7
7
  > vite build --config vite.esm.config.ts --mode production
8
8
 
9
9
  ViteEsmConfig: .
@@ -73,6 +73,6 @@ dist/util/configCreator.js 0.86 kB │ gzip: 0.45 kB
73
73
  dist/util/language.js 1.01 kB │ gzip: 0.44 kB
74
74
  dist/util/captcha/captchaRenderer.js 1.93 kB │ gzip: 0.70 kB
75
75
  dist/util/widgetFactory.js 2.52 kB │ gzip: 0.85 kB
76
- dist/index.js 6.11 kB │ gzip: 2.06 kB
76
+ dist/index.js 8.85 kB │ gzip: 3.14 kB
77
77
 
78
- ✓ built in 67ms
78
+ ✓ built in 51ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @prosopo/procaptcha-bundle
2
2
 
3
+ ## 4.1.50
4
+ ### Patch Changes
5
+
6
+ - 9f73b93: Make `reset()` remount the widget instead of only tearing it down.
7
+
8
+ `reset()` unmounted every React root and then called `start()`, which
9
+ re-renders only when the page uses implicit rendering. On an explicitly
10
+ rendered page nothing came back: the widget skeleton is plain DOM created
11
+ outside React, so it stayed on screen with no checkbox inside it, and no fresh
12
+ captcha request was ever made. Callers had to follow every `reset()` with their
13
+ own `render()` to recover.
14
+
15
+ Widgets are now tracked with the element and render options that produced them,
16
+ so `reset()` can rebuild in place. `render()` returns a widget id, and both
17
+ `reset(widgetId)` and the new `remove(widgetId)` accept one to target a single
18
+ widget; omitting it applies to every widget on the page. `remove()` preserves
19
+ the old teardown-without-remount behaviour for callers that want the widget
20
+ gone. `reset()` no longer calls `start()`, which would have double-rendered
21
+ implicit widgets and attached another `load` listener on every call.
22
+ - Updated dependencies [216f8cd]
23
+ - Updated dependencies [cc3ffe3]
24
+ - @prosopo/types@5.0.4
25
+ - @prosopo/procaptcha-common@2.11.24
26
+ - @prosopo/procaptcha-frictionless@2.13.6
27
+
3
28
  ## 4.1.49
4
29
  ### Patch Changes
5
30
 
@@ -9,7 +9,20 @@ let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
9
9
  let _prosopo_util = require("@prosopo/util");
10
10
  //#region src/index.ts
11
11
  var BUNDLE_NAMES = ["procaptcha.bundle.iife.js", "procaptcha.bundle.js"];
12
- var procaptchaRoots = [];
12
+ var procaptchaWidgets = /* @__PURE__ */ new Map();
13
+ var widgetIdCounter = 0;
14
+ var nextWidgetId = () => `procaptcha-widget-${widgetIdCounter++}`;
15
+ var registerWidgets = (roots, elements, renderOptions, isWeb2, invisible) => roots.map((root, index) => {
16
+ const id = nextWidgetId();
17
+ procaptchaWidgets.set(id, {
18
+ root,
19
+ element: (0, _prosopo_util.at)(elements, index),
20
+ renderOptions,
21
+ isWeb2,
22
+ invisible
23
+ });
24
+ return id;
25
+ });
13
26
  var widgetFactory = new require_widgetFactory.WidgetFactory(new require_widgetThemeResolver.WidgetThemeResolver());
14
27
  /**
15
28
  * Kick off provider resolution + detector assignment without blocking render.
@@ -46,12 +59,12 @@ var implicitRender = async () => {
46
59
  ipv4,
47
60
  ipv6
48
61
  });
49
- const root = await widgetFactory.createWidgets(elements, {
62
+ const implicitRenderOptions = {
50
63
  siteKey,
51
64
  ipv4,
52
65
  ipv6
53
- }, !(web3 === "true"));
54
- procaptchaRoots.push(...root);
66
+ };
67
+ registerWidgets(await widgetFactory.createWidgets(elements, implicitRenderOptions, !(web3 === "true")), elements, implicitRenderOptions, !(web3 === "true"), false);
55
68
  }
56
69
  const invisibleButtons = Array.from(document.getElementsByClassName("procaptcha")).filter((button) => button.tagName.toLowerCase() === "button");
57
70
  if (invisibleButtons.length) for (const button of invisibleButtons) {
@@ -63,30 +76,34 @@ var implicitRender = async () => {
63
76
  ipv4,
64
77
  ipv6
65
78
  });
66
- const root = await widgetFactory.createWidgets([button], {
79
+ const buttonRenderOptions = {
67
80
  siteKey,
68
81
  callback,
69
82
  ipv4,
70
83
  ipv6
71
- }, true, true);
72
- procaptchaRoots.push(...root);
84
+ };
85
+ registerWidgets(await widgetFactory.createWidgets([button], buttonRenderOptions, true, true), [button], buttonRenderOptions, true, true);
73
86
  button.addEventListener("click", async (event) => {
74
87
  event.preventDefault();
75
88
  execute();
76
89
  });
77
90
  }
78
91
  };
92
+ /**
93
+ * Renders a widget into `element` and returns its id, which `reset()` and
94
+ * `remove()` accept to target this widget alone. Previously this returned
95
+ * nothing, so callers had no handle on an individual widget and the only
96
+ * available reset was all-or-nothing.
97
+ *
98
+ * Returns undefined when no widget was created, rather than throwing — the
99
+ * factory legitimately yields nothing for an element it cannot mount into.
100
+ */
79
101
  var render = async (element, renderOptions) => {
80
102
  startDetectorPrefetch(renderOptions.siteKey, renderOptions);
81
103
  const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") && renderOptions.size === "invisible";
82
104
  const isWeb2 = !renderOptions.web3;
83
- if (hasInvisibleSize || element.tagName.toLowerCase() === "button") {
84
- const roots = await widgetFactory.createWidgets([element], renderOptions, isWeb2, true);
85
- procaptchaRoots.push(...roots);
86
- return;
87
- }
88
- const roots = await widgetFactory.createWidgets([element], renderOptions, isWeb2, false);
89
- procaptchaRoots.push(...roots);
105
+ const invisible = hasInvisibleSize || element.tagName.toLowerCase() === "button";
106
+ return registerWidgets(await widgetFactory.createWidgets([element], renderOptions, isWeb2, invisible), [element], renderOptions, isWeb2, invisible)[0];
90
107
  };
91
108
  function ready(fn) {
92
109
  if (document && document.readyState !== "loading") {
@@ -145,15 +162,58 @@ var start = () => {
145
162
  if (document.readyState === "complete" && !readyCalled) ready((0, _prosopo_procaptcha_common.getWindowCallback)(onloadUrlCallback));
146
163
  }
147
164
  };
148
- var reset = () => {
149
- for (const root of procaptchaRoots) root.unmount();
150
- procaptchaRoots = [];
151
- start();
165
+ /**
166
+ * Returns a widget to its unsolved state, ready to be solved again. Pass a
167
+ * widget id to reset one widget, or omit it to reset every widget on the page.
168
+ *
169
+ * This remounts rather than merely unmounting. The previous implementation
170
+ * unmounted every root and then called `start()`, which only re-renders when
171
+ * the page uses implicit rendering — and even then only via the
172
+ * `document.readyState` fallback, because the script's `load` event has long
173
+ * since fired. On an explicitly-rendered page nothing came back at all: the
174
+ * skeleton stayed in the DOM with no checkbox inside it, and no fresh captcha
175
+ * request was ever made. Rebuilding from the stored descriptor makes reset
176
+ * behave the same way on both paths.
177
+ *
178
+ * `start()` is deliberately not called here any more. It re-renders implicit
179
+ * widgets, which would double up with the remount below, and it attaches
180
+ * another `load` listener to the script tag on every call.
181
+ */
182
+ var reset = async (widgetId) => {
183
+ const ids = void 0 === widgetId ? Array.from(procaptchaWidgets.keys()) : [widgetId];
184
+ for (const id of ids) {
185
+ const current = procaptchaWidgets.get(id);
186
+ if (!current) continue;
187
+ current.root.unmount();
188
+ const [root] = await widgetFactory.createWidgets([current.element], current.renderOptions, current.isWeb2, current.invisible);
189
+ if (root) procaptchaWidgets.set(id, {
190
+ ...current,
191
+ root
192
+ });
193
+ else procaptchaWidgets.delete(id);
194
+ }
195
+ };
196
+ /**
197
+ * Tears a widget down without putting it back — the behaviour `reset()` used
198
+ * to have by accident on explicitly-rendered pages, kept as an explicit
199
+ * operation for callers that genuinely want the widget gone (a closing modal,
200
+ * an SPA route change).
201
+ */
202
+ var remove = (widgetId) => {
203
+ const ids = void 0 === widgetId ? Array.from(procaptchaWidgets.keys()) : [widgetId];
204
+ for (const id of ids) {
205
+ const entry = procaptchaWidgets.get(id);
206
+ if (!entry) continue;
207
+ entry.root.unmount();
208
+ entry.element.innerHTML = "";
209
+ procaptchaWidgets.delete(id);
210
+ }
152
211
  };
153
212
  window.procaptcha = {
154
213
  ready,
155
214
  render,
156
215
  reset,
216
+ remove,
157
217
  execute
158
218
  };
159
219
  var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
@@ -166,5 +226,6 @@ start();
166
226
  //#endregion
167
227
  exports.default = ready;
168
228
  exports.execute = execute;
229
+ exports.remove = remove;
169
230
  exports.render = render;
170
231
  exports.reset = reset;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ProcaptchaRenderOptions } from "@prosopo/types";
2
- export declare const render: (element: Element, renderOptions: ProcaptchaRenderOptions) => Promise<void>;
2
+ export declare const render: (element: Element, renderOptions: ProcaptchaRenderOptions) => Promise<string | undefined>;
3
3
  export default function ready(fn: () => void): void;
4
4
  export declare const execute: () => void;
5
5
  declare global {
@@ -8,9 +8,11 @@ declare global {
8
8
  ready: typeof ready;
9
9
  render: typeof render;
10
10
  reset: typeof reset;
11
+ remove: typeof remove;
11
12
  execute: typeof execute;
12
13
  };
13
14
  }
14
15
  }
15
- export declare const reset: () => void;
16
+ export declare const reset: (widgetId?: string) => Promise<void>;
17
+ export declare const remove: (widgetId?: string) => void;
16
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAe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1C,CAAC"}
package/dist/index.js CHANGED
@@ -6,7 +6,20 @@ import { getWindowCallback } from "@prosopo/procaptcha-common";
6
6
  import { at } from "@prosopo/util";
7
7
  //#region src/index.ts
8
8
  var BUNDLE_NAMES = ["procaptcha.bundle.iife.js", "procaptcha.bundle.js"];
9
- var procaptchaRoots = [];
9
+ var procaptchaWidgets = /* @__PURE__ */ new Map();
10
+ var widgetIdCounter = 0;
11
+ var nextWidgetId = () => `procaptcha-widget-${widgetIdCounter++}`;
12
+ var registerWidgets = (roots, elements, renderOptions, isWeb2, invisible) => roots.map((root, index) => {
13
+ const id = nextWidgetId();
14
+ procaptchaWidgets.set(id, {
15
+ root,
16
+ element: at(elements, index),
17
+ renderOptions,
18
+ isWeb2,
19
+ invisible
20
+ });
21
+ return id;
22
+ });
10
23
  var widgetFactory = new WidgetFactory(new WidgetThemeResolver());
11
24
  /**
12
25
  * Kick off provider resolution + detector assignment without blocking render.
@@ -43,12 +56,12 @@ var implicitRender = async () => {
43
56
  ipv4,
44
57
  ipv6
45
58
  });
46
- const root = await widgetFactory.createWidgets(elements, {
59
+ const implicitRenderOptions = {
47
60
  siteKey,
48
61
  ipv4,
49
62
  ipv6
50
- }, !(web3 === "true"));
51
- procaptchaRoots.push(...root);
63
+ };
64
+ registerWidgets(await widgetFactory.createWidgets(elements, implicitRenderOptions, !(web3 === "true")), elements, implicitRenderOptions, !(web3 === "true"), false);
52
65
  }
53
66
  const invisibleButtons = Array.from(document.getElementsByClassName("procaptcha")).filter((button) => button.tagName.toLowerCase() === "button");
54
67
  if (invisibleButtons.length) for (const button of invisibleButtons) {
@@ -60,30 +73,34 @@ var implicitRender = async () => {
60
73
  ipv4,
61
74
  ipv6
62
75
  });
63
- const root = await widgetFactory.createWidgets([button], {
76
+ const buttonRenderOptions = {
64
77
  siteKey,
65
78
  callback,
66
79
  ipv4,
67
80
  ipv6
68
- }, true, true);
69
- procaptchaRoots.push(...root);
81
+ };
82
+ registerWidgets(await widgetFactory.createWidgets([button], buttonRenderOptions, true, true), [button], buttonRenderOptions, true, true);
70
83
  button.addEventListener("click", async (event) => {
71
84
  event.preventDefault();
72
85
  execute();
73
86
  });
74
87
  }
75
88
  };
89
+ /**
90
+ * Renders a widget into `element` and returns its id, which `reset()` and
91
+ * `remove()` accept to target this widget alone. Previously this returned
92
+ * nothing, so callers had no handle on an individual widget and the only
93
+ * available reset was all-or-nothing.
94
+ *
95
+ * Returns undefined when no widget was created, rather than throwing — the
96
+ * factory legitimately yields nothing for an element it cannot mount into.
97
+ */
76
98
  var render = async (element, renderOptions) => {
77
99
  startDetectorPrefetch(renderOptions.siteKey, renderOptions);
78
100
  const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") && renderOptions.size === "invisible";
79
101
  const isWeb2 = !renderOptions.web3;
80
- if (hasInvisibleSize || element.tagName.toLowerCase() === "button") {
81
- const roots = await widgetFactory.createWidgets([element], renderOptions, isWeb2, true);
82
- procaptchaRoots.push(...roots);
83
- return;
84
- }
85
- const roots = await widgetFactory.createWidgets([element], renderOptions, isWeb2, false);
86
- procaptchaRoots.push(...roots);
102
+ const invisible = hasInvisibleSize || element.tagName.toLowerCase() === "button";
103
+ return registerWidgets(await widgetFactory.createWidgets([element], renderOptions, isWeb2, invisible), [element], renderOptions, isWeb2, invisible)[0];
87
104
  };
88
105
  function ready(fn) {
89
106
  if (document && document.readyState !== "loading") {
@@ -142,15 +159,58 @@ var start = () => {
142
159
  if (document.readyState === "complete" && !readyCalled) ready(getWindowCallback(onloadUrlCallback));
143
160
  }
144
161
  };
145
- var reset = () => {
146
- for (const root of procaptchaRoots) root.unmount();
147
- procaptchaRoots = [];
148
- start();
162
+ /**
163
+ * Returns a widget to its unsolved state, ready to be solved again. Pass a
164
+ * widget id to reset one widget, or omit it to reset every widget on the page.
165
+ *
166
+ * This remounts rather than merely unmounting. The previous implementation
167
+ * unmounted every root and then called `start()`, which only re-renders when
168
+ * the page uses implicit rendering — and even then only via the
169
+ * `document.readyState` fallback, because the script's `load` event has long
170
+ * since fired. On an explicitly-rendered page nothing came back at all: the
171
+ * skeleton stayed in the DOM with no checkbox inside it, and no fresh captcha
172
+ * request was ever made. Rebuilding from the stored descriptor makes reset
173
+ * behave the same way on both paths.
174
+ *
175
+ * `start()` is deliberately not called here any more. It re-renders implicit
176
+ * widgets, which would double up with the remount below, and it attaches
177
+ * another `load` listener to the script tag on every call.
178
+ */
179
+ var reset = async (widgetId) => {
180
+ const ids = void 0 === widgetId ? Array.from(procaptchaWidgets.keys()) : [widgetId];
181
+ for (const id of ids) {
182
+ const current = procaptchaWidgets.get(id);
183
+ if (!current) continue;
184
+ current.root.unmount();
185
+ const [root] = await widgetFactory.createWidgets([current.element], current.renderOptions, current.isWeb2, current.invisible);
186
+ if (root) procaptchaWidgets.set(id, {
187
+ ...current,
188
+ root
189
+ });
190
+ else procaptchaWidgets.delete(id);
191
+ }
192
+ };
193
+ /**
194
+ * Tears a widget down without putting it back — the behaviour `reset()` used
195
+ * to have by accident on explicitly-rendered pages, kept as an explicit
196
+ * operation for callers that genuinely want the widget gone (a closing modal,
197
+ * an SPA route change).
198
+ */
199
+ var remove = (widgetId) => {
200
+ const ids = void 0 === widgetId ? Array.from(procaptchaWidgets.keys()) : [widgetId];
201
+ for (const id of ids) {
202
+ const entry = procaptchaWidgets.get(id);
203
+ if (!entry) continue;
204
+ entry.root.unmount();
205
+ entry.element.innerHTML = "";
206
+ procaptchaWidgets.delete(id);
207
+ }
149
208
  };
150
209
  window.procaptcha = {
151
210
  ready,
152
211
  render,
153
212
  reset,
213
+ remove,
154
214
  execute
155
215
  };
156
216
  var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
@@ -161,4 +221,4 @@ var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
161
221
  document.dispatchEvent(procaptchaReadyEvent);
162
222
  start();
163
223
  //#endregion
164
- export { ready as default, execute, render, reset };
224
+ export { ready as default, execute, remove, render, reset };
package/dist/index.js.map C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;IAE5E,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7B,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;AACF,CAAC,CAAC;AAGF,MAAM,CAAC,UAAU,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAG9D,MAAM,oBAAoB,GAAG,IAAI,WAAW,CAAC,sBAAsB,EAAE;IACpE,MAAM,EAAE;QACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACrB;IACD,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,KAAK;CACjB,CAAC,CAAC;AACH,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAE7C,KAAK,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=reset.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.unit.test.d.ts","sourceRoot":"","sources":["../../src/tests/reset.unit.test.ts"],"names":[],"mappings":""}