@captchafox/react 1.1.0 → 1.2.0

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,32 @@
1
+ "use client";
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
30
  var __async = (__this, __arguments, generator) => {
2
31
  return new Promise((resolve, reject) => {
3
32
  var fulfilled = (value) => {
@@ -19,6 +48,14 @@ var __async = (__this, __arguments, generator) => {
19
48
  });
20
49
  };
21
50
 
51
+ // src/index.tsx
52
+ var src_exports = {};
53
+ __export(src_exports, {
54
+ CAPTCHA_RESPONSE_KEY: () => CAPTCHA_RESPONSE_KEY,
55
+ CaptchaFox: () => CaptchaFox
56
+ });
57
+ module.exports = __toCommonJS(src_exports);
58
+
22
59
  // ../internal/dist/index.mjs
23
60
  var resolveFn;
24
61
  var rejectFn;
@@ -45,14 +82,13 @@ function loadCaptchaScript() {
45
82
  var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !== "undefined";
46
83
 
47
84
  // src/CaptchaFox.tsx
48
- import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
49
- import { jsx } from "react/jsx-runtime";
50
- var CaptchaFox = forwardRef(
85
+ var import_react = __toESM(require("react"), 1);
86
+ var CaptchaFox = (0, import_react.forwardRef)(
51
87
  ({ 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(
88
+ const [containerRef, setContainerRef] = (0, import_react.useState)();
89
+ const [widgetId, setWidgetId] = (0, import_react.useState)();
90
+ const firstRendered = (0, import_react.useRef)(false);
91
+ (0, import_react.useImperativeHandle)(
56
92
  ref,
57
93
  () => {
58
94
  return {
@@ -105,7 +141,7 @@ var CaptchaFox = forwardRef(
105
141
  setWidgetId(newWidgetId);
106
142
  onLoad == null ? void 0 : onLoad();
107
143
  });
108
- useEffect(() => {
144
+ (0, import_react.useEffect)(() => {
109
145
  if (!containerRef)
110
146
  return;
111
147
  if (firstRendered.current) {
@@ -124,14 +160,15 @@ var CaptchaFox = forwardRef(
124
160
  });
125
161
  }
126
162
  }, [containerRef, sitekey, lang, mode]);
127
- return /* @__PURE__ */ jsx("div", { ref: setContainerRef, id: widgetId, className });
163
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: setContainerRef, id: widgetId, className });
128
164
  }
129
165
  );
130
166
  CaptchaFox.displayName = "CaptchaFox";
131
167
 
132
168
  // src/index.tsx
133
169
  var CAPTCHA_RESPONSE_KEY = "cf-captcha-response";
134
- export {
170
+ // Annotate the CommonJS export names for ESM import in node:
171
+ 0 && (module.exports = {
135
172
  CAPTCHA_RESPONSE_KEY,
136
173
  CaptchaFox
137
- };
174
+ });
@@ -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,4 @@
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);
1
+ "use client";
19
2
  var __async = (__this, __arguments, generator) => {
20
3
  return new Promise((resolve, reject) => {
21
4
  var fulfilled = (value) => {
@@ -37,14 +20,6 @@ var __async = (__this, __arguments, generator) => {
37
20
  });
38
21
  };
39
22
 
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
23
  // ../internal/dist/index.mjs
49
24
  var resolveFn;
50
25
  var rejectFn;
@@ -71,14 +46,13 @@ function loadCaptchaScript() {
71
46
  var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !== "undefined";
72
47
 
73
48
  // 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)(
49
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
50
+ var CaptchaFox = forwardRef(
77
51
  ({ 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)(
52
+ const [containerRef, setContainerRef] = useState();
53
+ const [widgetId, setWidgetId] = useState();
54
+ const firstRendered = useRef(false);
55
+ useImperativeHandle(
82
56
  ref,
83
57
  () => {
84
58
  return {
@@ -131,7 +105,7 @@ var CaptchaFox = (0, import_react.forwardRef)(
131
105
  setWidgetId(newWidgetId);
132
106
  onLoad == null ? void 0 : onLoad();
133
107
  });
134
- (0, import_react.useEffect)(() => {
108
+ useEffect(() => {
135
109
  if (!containerRef)
136
110
  return;
137
111
  if (firstRendered.current) {
@@ -150,15 +124,14 @@ var CaptchaFox = (0, import_react.forwardRef)(
150
124
  });
151
125
  }
152
126
  }, [containerRef, sitekey, lang, mode]);
153
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: setContainerRef, id: widgetId, className });
127
+ return /* @__PURE__ */ React.createElement("div", { ref: setContainerRef, id: widgetId, className });
154
128
  }
155
129
  );
156
130
  CaptchaFox.displayName = "CaptchaFox";
157
131
 
158
132
  // src/index.tsx
159
133
  var CAPTCHA_RESPONSE_KEY = "cf-captcha-response";
160
- // Annotate the CommonJS export names for ESM import in node:
161
- 0 && (module.exports = {
134
+ export {
162
135
  CAPTCHA_RESPONSE_KEY,
163
136
  CaptchaFox
164
- });
137
+ };
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.2.0",
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
  },
@@ -22,8 +23,8 @@
22
23
  "dist"
23
24
  ],
24
25
  "scripts": {
25
- "build": "tsup src/index.tsx --format esm,cjs --dts --external react",
26
- "dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react",
26
+ "build": "tsup src/index.tsx ",
27
+ "dev": "tsup src/index.tsx --watch",
27
28
  "lint": "eslint \"src/**/*.ts*\"",
28
29
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
29
30
  "test": "jest --coverage",
@@ -37,21 +38,26 @@
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
- "@testing-library/user-event": "^14.4.3",
43
- "@testing-library/jest-dom": "^5.16.5",
44
- "@types/jest": "^29.5.0",
45
- "@types/react": "^18.0.9",
46
- "@types/react-dom": "^18.0.4",
47
- "eslint": "^8.15.0",
44
+ "@testing-library/user-event": "^14.5.1",
45
+ "@testing-library/jest-dom": "^6.1.3",
46
+ "@types/jest": "^29.5.5",
47
+ "@types/react": "^18.2.25",
48
+ "@types/react-dom": "^18.2.11",
48
49
  "eslint-config-captchafox": "*",
49
- "jest": "^29.5.0",
50
- "jest-environment-jsdom": "^29.5.0",
51
- "react": "^18.1.0",
52
- "tsup": "^7.1.0",
53
- "ts-jest": "^29.0.5",
54
- "typescript": "^4.9.5"
50
+ "jest": "^29.7.0",
51
+ "jest-environment-jsdom": "^29.7.0",
52
+ "react": "^18.2.0",
53
+ "tsup": "^7.2.0",
54
+ "ts-jest": "^29.1.1",
55
+ "typescript": "^5.0.2"
56
+ },
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "https://github.com/CaptchaFox/javascript-integrations.git",
60
+ "directory": "packages/react"
55
61
  },
56
62
  "bugs": {
57
63
  "url": "https://github.com/CaptchaFox/javascript-integrations/issues"