@captchafox/react 1.1.0 → 1.1.1

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,3 +1,31 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
29
  var __async = (__this, __arguments, generator) => {
2
30
  return new Promise((resolve, reject) => {
3
31
  var fulfilled = (value) => {
@@ -19,6 +47,14 @@ var __async = (__this, __arguments, generator) => {
19
47
  });
20
48
  };
21
49
 
50
+ // src/index.tsx
51
+ var src_exports = {};
52
+ __export(src_exports, {
53
+ CAPTCHA_RESPONSE_KEY: () => CAPTCHA_RESPONSE_KEY,
54
+ CaptchaFox: () => CaptchaFox
55
+ });
56
+ module.exports = __toCommonJS(src_exports);
57
+
22
58
  // ../internal/dist/index.mjs
23
59
  var resolveFn;
24
60
  var rejectFn;
@@ -45,14 +81,13 @@ function loadCaptchaScript() {
45
81
  var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !== "undefined";
46
82
 
47
83
  // src/CaptchaFox.tsx
48
- import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
49
- import { jsx } from "react/jsx-runtime";
50
- var CaptchaFox = forwardRef(
84
+ var import_react = __toESM(require("react"), 1);
85
+ var CaptchaFox = (0, import_react.forwardRef)(
51
86
  ({ sitekey, lang, mode, className, onError, onVerify, onLoad, onFail, onClose }, ref) => {
52
- const [containerRef, setContainerRef] = useState();
53
- const [widgetId, setWidgetId] = useState();
54
- const firstRendered = useRef(false);
55
- useImperativeHandle(
87
+ const [containerRef, setContainerRef] = (0, import_react.useState)();
88
+ const [widgetId, setWidgetId] = (0, import_react.useState)();
89
+ const firstRendered = (0, import_react.useRef)(false);
90
+ (0, import_react.useImperativeHandle)(
56
91
  ref,
57
92
  () => {
58
93
  return {
@@ -105,7 +140,7 @@ var CaptchaFox = forwardRef(
105
140
  setWidgetId(newWidgetId);
106
141
  onLoad == null ? void 0 : onLoad();
107
142
  });
108
- useEffect(() => {
143
+ (0, import_react.useEffect)(() => {
109
144
  if (!containerRef)
110
145
  return;
111
146
  if (firstRendered.current) {
@@ -124,14 +159,15 @@ var CaptchaFox = forwardRef(
124
159
  });
125
160
  }
126
161
  }, [containerRef, sitekey, lang, mode]);
127
- return /* @__PURE__ */ jsx("div", { ref: setContainerRef, id: widgetId, className });
162
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: setContainerRef, id: widgetId, className });
128
163
  }
129
164
  );
130
165
  CaptchaFox.displayName = "CaptchaFox";
131
166
 
132
167
  // src/index.tsx
133
168
  var CAPTCHA_RESPONSE_KEY = "cf-captcha-response";
134
- export {
169
+ // Annotate the CommonJS export names for ESM import in node:
170
+ 0 && (module.exports = {
135
171
  CAPTCHA_RESPONSE_KEY,
136
172
  CaptchaFox
137
- };
173
+ });
@@ -1,12 +1,12 @@
1
- import * as react from 'react';
2
1
  import { WidgetApi, WidgetOptions } from '@captchafox/types';
2
+ import React from 'react';
3
3
 
4
4
  type CaptchaFoxInstance = Omit<WidgetApi, 'render'>;
5
- declare const CaptchaFox: react.ForwardRefExoticComponent<WidgetOptions & {
5
+ declare const CaptchaFox: React.ForwardRefExoticComponent<WidgetOptions & {
6
6
  /** Called after the widget has been loaded */
7
7
  onLoad?: (() => void) | undefined;
8
8
  className?: string | undefined;
9
- } & react.RefAttributes<CaptchaFoxInstance>>;
9
+ } & React.RefAttributes<CaptchaFoxInstance>>;
10
10
 
11
11
  declare const CAPTCHA_RESPONSE_KEY = "cf-captcha-response";
12
12
 
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import * as react from 'react';
2
1
  import { WidgetApi, WidgetOptions } from '@captchafox/types';
2
+ import React from 'react';
3
3
 
4
4
  type CaptchaFoxInstance = Omit<WidgetApi, 'render'>;
5
- declare const CaptchaFox: react.ForwardRefExoticComponent<WidgetOptions & {
5
+ declare const CaptchaFox: React.ForwardRefExoticComponent<WidgetOptions & {
6
6
  /** Called after the widget has been loaded */
7
7
  onLoad?: (() => void) | undefined;
8
8
  className?: string | undefined;
9
- } & react.RefAttributes<CaptchaFoxInstance>>;
9
+ } & React.RefAttributes<CaptchaFoxInstance>>;
10
10
 
11
11
  declare const CAPTCHA_RESPONSE_KEY = "cf-captcha-response";
12
12
 
package/dist/index.js CHANGED
@@ -1,21 +1,3 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
1
  var __async = (__this, __arguments, generator) => {
20
2
  return new Promise((resolve, reject) => {
21
3
  var fulfilled = (value) => {
@@ -37,14 +19,6 @@ var __async = (__this, __arguments, generator) => {
37
19
  });
38
20
  };
39
21
 
40
- // src/index.tsx
41
- var src_exports = {};
42
- __export(src_exports, {
43
- CAPTCHA_RESPONSE_KEY: () => CAPTCHA_RESPONSE_KEY,
44
- CaptchaFox: () => CaptchaFox
45
- });
46
- module.exports = __toCommonJS(src_exports);
47
-
48
22
  // ../internal/dist/index.mjs
49
23
  var resolveFn;
50
24
  var rejectFn;
@@ -71,14 +45,13 @@ function loadCaptchaScript() {
71
45
  var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !== "undefined";
72
46
 
73
47
  // src/CaptchaFox.tsx
74
- var import_react = require("react");
75
- var import_jsx_runtime = require("react/jsx-runtime");
76
- var CaptchaFox = (0, import_react.forwardRef)(
48
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
49
+ var CaptchaFox = forwardRef(
77
50
  ({ sitekey, lang, mode, className, onError, onVerify, onLoad, onFail, onClose }, ref) => {
78
- const [containerRef, setContainerRef] = (0, import_react.useState)();
79
- const [widgetId, setWidgetId] = (0, import_react.useState)();
80
- const firstRendered = (0, import_react.useRef)(false);
81
- (0, import_react.useImperativeHandle)(
51
+ const [containerRef, setContainerRef] = useState();
52
+ const [widgetId, setWidgetId] = useState();
53
+ const firstRendered = useRef(false);
54
+ useImperativeHandle(
82
55
  ref,
83
56
  () => {
84
57
  return {
@@ -131,7 +104,7 @@ var CaptchaFox = (0, import_react.forwardRef)(
131
104
  setWidgetId(newWidgetId);
132
105
  onLoad == null ? void 0 : onLoad();
133
106
  });
134
- (0, import_react.useEffect)(() => {
107
+ useEffect(() => {
135
108
  if (!containerRef)
136
109
  return;
137
110
  if (firstRendered.current) {
@@ -150,15 +123,14 @@ var CaptchaFox = (0, import_react.forwardRef)(
150
123
  });
151
124
  }
152
125
  }, [containerRef, sitekey, lang, mode]);
153
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: setContainerRef, id: widgetId, className });
126
+ return /* @__PURE__ */ React.createElement("div", { ref: setContainerRef, id: widgetId, className });
154
127
  }
155
128
  );
156
129
  CaptchaFox.displayName = "CaptchaFox";
157
130
 
158
131
  // src/index.tsx
159
132
  var CAPTCHA_RESPONSE_KEY = "cf-captcha-response";
160
- // Annotate the CommonJS export names for ESM import in node:
161
- 0 && (module.exports = {
133
+ export {
162
134
  CAPTCHA_RESPONSE_KEY,
163
135
  CaptchaFox
164
- });
136
+ };
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@captchafox/react",
3
- "version": "1.1.0",
4
- "main": "./dist/index.js",
5
- "module": "./dist/index.mjs",
3
+ "version": "1.1.1",
4
+ "main": "./dist/index.cjs",
5
+ "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "sideEffects": false,
8
8
  "license": "MIT",
9
+ "type": "module",
9
10
  "exports": {
10
11
  ".": {
11
12
  "import": {
12
- "types": "./dist/index.d.mts",
13
- "default": "./dist/index.mjs"
14
- },
15
- "require": {
16
13
  "types": "./dist/index.d.ts",
17
14
  "default": "./dist/index.js"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
18
19
  }
19
20
  }
20
21
  },
@@ -37,6 +38,7 @@
37
38
  "@captchafox/types": "^1.1.0"
38
39
  },
39
40
  "devDependencies": {
41
+ "@captchafox/tsconfig": "*",
40
42
  "@captchafox/internal": "*",
41
43
  "@testing-library/react": "^14.0.0",
42
44
  "@testing-library/user-event": "^14.4.3",
@@ -51,7 +53,12 @@
51
53
  "react": "^18.1.0",
52
54
  "tsup": "^7.1.0",
53
55
  "ts-jest": "^29.0.5",
54
- "typescript": "^4.9.5"
56
+ "typescript": "^5.0.2"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "https://github.com/CaptchaFox/javascript-integrations.git",
61
+ "directory": "packages/react"
55
62
  },
56
63
  "bugs": {
57
64
  "url": "https://github.com/CaptchaFox/javascript-integrations/issues"