@prosopo/procaptcha-wrapper 2.6.46 → 2.6.78
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/.turbo/turbo-build$colon$cjs.log +2 -2
- package/.turbo/turbo-build$colon$tsc.log +9 -9
- package/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +213 -0
- package/package.json +10 -5
- package/src/index.ts +31 -0
- package/src/render/renderFunction.ts +81 -0
- package/src/render/renderer.ts +51 -0
- package/tsconfig.cjs.json +19 -0
- package/tsconfig.json +25 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsconfig.types.json +9 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-wrapper@2.6.
|
|
2
|
+
> @prosopo/procaptcha-wrapper@2.6.78 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -28,4 +28,4 @@ rendering chunks...
|
|
|
28
28
|
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m0.38 kB[22m[1m[22m
|
|
29
29
|
[2mdist/cjs/[22m[36mrender/renderer.cjs [39m[1m[2m0.69 kB[22m[1m[22m
|
|
30
30
|
[2mdist/cjs/[22m[36mrender/renderFunction.cjs [39m[1m[2m1.00 kB[22m[1m[22m
|
|
31
|
-
[32m✓ built in
|
|
31
|
+
[32m✓ built in 152ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-wrapper@2.6.
|
|
2
|
+
> @prosopo/procaptcha-wrapper@2.6.78 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
7:53:13 AM - Projects in this build:
|
|
6
6
|
* ../../dev/config/tsconfig.json
|
|
7
7
|
* ../locale/tsconfig.json
|
|
8
8
|
* ../util/tsconfig.json
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
* ../types/tsconfig.json
|
|
11
11
|
* tsconfig.json
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
7:53:13 AM - 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'
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
7:53:13 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
7:53:13 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
7:53:13 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'
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
7:53:13 AM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/procaptcha/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
7:53:13 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
7:53:13 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-wrapper/tsconfig.json'...
|
|
26
26
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-wrapper@2.6.
|
|
2
|
+
> @prosopo/procaptcha-wrapper@2.6.78 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/procaptcha-wrapper@2.6.
|
|
6
|
+
> @prosopo/procaptcha-wrapper@2.6.78 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -32,4 +32,4 @@ rendering chunks...
|
|
|
32
32
|
[2mdist/[22m[36mindex.js [39m[1m[2m0.27 kB[22m[1m[22m
|
|
33
33
|
[2mdist/[22m[36mrender/renderer.js [39m[1m[2m0.57 kB[22m[1m[22m
|
|
34
34
|
[2mdist/[22m[36mrender/renderFunction.js [39m[1m[2m0.90 kB[22m[1m[22m
|
|
35
|
-
[32m✓ built in
|
|
35
|
+
[32m✓ built in 186ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,218 @@
|
|
|
1
1
|
# @prosopo/procaptcha-wrapper
|
|
2
2
|
|
|
3
|
+
## 2.6.78
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- Updated dependencies [a1d60db]
|
|
7
|
+
- Updated dependencies [2392aaf]
|
|
8
|
+
- @prosopo/types@4.3.0
|
|
9
|
+
|
|
10
|
+
## 2.6.77
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [6c26669]
|
|
14
|
+
- Updated dependencies [f7f9ec5]
|
|
15
|
+
- @prosopo/types@4.2.1
|
|
16
|
+
|
|
17
|
+
## 2.6.76
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [20cae63]
|
|
21
|
+
- Updated dependencies [4d9923e]
|
|
22
|
+
- @prosopo/types@4.2.0
|
|
23
|
+
|
|
24
|
+
## 2.6.75
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [d351362]
|
|
28
|
+
- @prosopo/types@4.1.4
|
|
29
|
+
|
|
30
|
+
## 2.6.74
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [e2711ae]
|
|
34
|
+
- Updated dependencies [5786629]
|
|
35
|
+
- @prosopo/types@4.1.3
|
|
36
|
+
- @prosopo/locale@3.2.4
|
|
37
|
+
|
|
38
|
+
## 2.6.73
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- @prosopo/types@4.1.2
|
|
42
|
+
|
|
43
|
+
## 2.6.72
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [53bfd45]
|
|
47
|
+
- Updated dependencies [91958da]
|
|
48
|
+
- @prosopo/locale@3.2.3
|
|
49
|
+
- @prosopo/types@4.1.1
|
|
50
|
+
|
|
51
|
+
## 2.6.71
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [6a741ce]
|
|
55
|
+
- @prosopo/types@4.1.0
|
|
56
|
+
|
|
57
|
+
## 2.6.70
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [3c0be68]
|
|
61
|
+
- Updated dependencies [f9ea09d]
|
|
62
|
+
- Updated dependencies [4aae4e6]
|
|
63
|
+
- Updated dependencies [d865319]
|
|
64
|
+
- Updated dependencies [753304b]
|
|
65
|
+
- Updated dependencies [8bb7286]
|
|
66
|
+
- Updated dependencies [f9ea09d]
|
|
67
|
+
- Updated dependencies [4aae4e6]
|
|
68
|
+
- @prosopo/types@4.0.0
|
|
69
|
+
- @prosopo/locale@3.2.2
|
|
70
|
+
|
|
71
|
+
## 2.6.69
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [819ed95]
|
|
75
|
+
- @prosopo/types@3.16.1
|
|
76
|
+
|
|
77
|
+
## 2.6.68
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- Updated dependencies [f6a4402]
|
|
81
|
+
- Updated dependencies [99dfb44]
|
|
82
|
+
- @prosopo/types@3.16.0
|
|
83
|
+
|
|
84
|
+
## 2.6.67
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [3e54c0a]
|
|
88
|
+
- @prosopo/types@3.15.0
|
|
89
|
+
|
|
90
|
+
## 2.6.66
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [946a8ba]
|
|
94
|
+
- Updated dependencies [5614814]
|
|
95
|
+
- Updated dependencies [b94890c]
|
|
96
|
+
- @prosopo/types@3.14.1
|
|
97
|
+
- @prosopo/locale@3.2.1
|
|
98
|
+
|
|
99
|
+
## 2.6.65
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [fc514dd]
|
|
103
|
+
- Updated dependencies [42650db]
|
|
104
|
+
- @prosopo/locale@3.2.0
|
|
105
|
+
- @prosopo/types@3.14.0
|
|
106
|
+
|
|
107
|
+
## 2.6.64
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- @prosopo/types@3.13.3
|
|
111
|
+
|
|
112
|
+
## 2.6.63
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- @prosopo/types@3.13.2
|
|
116
|
+
|
|
117
|
+
## 2.6.62
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- @prosopo/types@3.13.1
|
|
121
|
+
|
|
122
|
+
## 2.6.61
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- Updated dependencies [e6d9553]
|
|
126
|
+
- @prosopo/types@3.13.0
|
|
127
|
+
|
|
128
|
+
## 2.6.60
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- Updated dependencies [d5082a9]
|
|
132
|
+
- Updated dependencies [e1ea65f]
|
|
133
|
+
- Updated dependencies [c316257]
|
|
134
|
+
- @prosopo/types@3.12.3
|
|
135
|
+
|
|
136
|
+
## 2.6.59
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies [adb89a6]
|
|
140
|
+
- @prosopo/locale@3.1.29
|
|
141
|
+
- @prosopo/types@3.12.2
|
|
142
|
+
|
|
143
|
+
## 2.6.58
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- Updated dependencies [a90eb54]
|
|
147
|
+
- @prosopo/types@3.12.1
|
|
148
|
+
|
|
149
|
+
## 2.6.57
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- Updated dependencies [676c5f2]
|
|
153
|
+
- Updated dependencies [feaca02]
|
|
154
|
+
- @prosopo/types@3.12.0
|
|
155
|
+
|
|
156
|
+
## 2.6.56
|
|
157
|
+
### Patch Changes
|
|
158
|
+
|
|
159
|
+
- Updated dependencies [8148587]
|
|
160
|
+
- @prosopo/types@3.11.1
|
|
161
|
+
|
|
162
|
+
## 2.6.55
|
|
163
|
+
### Patch Changes
|
|
164
|
+
|
|
165
|
+
- Updated dependencies [7f6ffc5]
|
|
166
|
+
- @prosopo/types@3.11.0
|
|
167
|
+
|
|
168
|
+
## 2.6.54
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- Updated dependencies [93fa086]
|
|
172
|
+
- @prosopo/types@3.10.2
|
|
173
|
+
|
|
174
|
+
## 2.6.53
|
|
175
|
+
### Patch Changes
|
|
176
|
+
|
|
177
|
+
- Updated dependencies [cde7550]
|
|
178
|
+
- @prosopo/types@3.10.1
|
|
179
|
+
|
|
180
|
+
## 2.6.52
|
|
181
|
+
### Patch Changes
|
|
182
|
+
|
|
183
|
+
- Updated dependencies [ad6d622]
|
|
184
|
+
- @prosopo/types@3.10.0
|
|
185
|
+
|
|
186
|
+
## 2.6.51
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- Updated dependencies [ff58a70]
|
|
190
|
+
- @prosopo/types@3.9.0
|
|
191
|
+
|
|
192
|
+
## 2.6.50
|
|
193
|
+
### Patch Changes
|
|
194
|
+
|
|
195
|
+
- Updated dependencies [d2431cd]
|
|
196
|
+
- @prosopo/types@3.8.4
|
|
197
|
+
|
|
198
|
+
## 2.6.49
|
|
199
|
+
### Patch Changes
|
|
200
|
+
|
|
201
|
+
- Updated dependencies [bd6995b]
|
|
202
|
+
- @prosopo/types@3.8.3
|
|
203
|
+
|
|
204
|
+
## 2.6.48
|
|
205
|
+
### Patch Changes
|
|
206
|
+
|
|
207
|
+
- Updated dependencies [9633e58]
|
|
208
|
+
- @prosopo/types@3.8.2
|
|
209
|
+
|
|
210
|
+
## 2.6.47
|
|
211
|
+
### Patch Changes
|
|
212
|
+
|
|
213
|
+
- Updated dependencies [f52a5c1]
|
|
214
|
+
- @prosopo/types@3.8.1
|
|
215
|
+
|
|
3
216
|
## 2.6.46
|
|
4
217
|
### Patch Changes
|
|
5
218
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-wrapper",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.78",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "^24",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"typecheck": "tsc --project tsconfig.types.json"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@prosopo/types": "3.
|
|
28
|
-
"@prosopo/locale": "3.
|
|
27
|
+
"@prosopo/types": "4.3.0",
|
|
28
|
+
"@prosopo/locale": "3.2.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@prosopo/config": "3.3.
|
|
31
|
+
"@prosopo/config": "3.3.1",
|
|
32
32
|
"@types/node": "22.10.2",
|
|
33
33
|
"del-cli": "6.0.0"
|
|
34
34
|
},
|
|
@@ -42,5 +42,10 @@
|
|
|
42
42
|
"url": "https://github.com/prosopo/captcha/issues"
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
45
|
-
"sideEffects": false
|
|
45
|
+
"sideEffects": false,
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/prosopo/captcha.git",
|
|
49
|
+
"directory": "packages/procaptcha-wrapper"
|
|
50
|
+
}
|
|
46
51
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import type { Languages } from "@prosopo/locale";
|
|
16
|
+
import type { CaptchaType, ProcaptchaRenderOptions } from "@prosopo/types";
|
|
17
|
+
import type { RendererFunction } from "./render/renderFunction.js";
|
|
18
|
+
import { createRenderer } from "./render/renderer.js";
|
|
19
|
+
|
|
20
|
+
export const renderProcaptcha: RendererFunction = createRenderer({
|
|
21
|
+
// @ts-expect-error
|
|
22
|
+
scriptUrl: import.meta.env.VITE_RENDER_SCRIPT_URL,
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
scriptId: import.meta.env.VITE_RENDER_SCRIPT_ID,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type {
|
|
28
|
+
ProcaptchaRenderOptions,
|
|
29
|
+
CaptchaType as ProcaptchaType,
|
|
30
|
+
Languages as ProcaptchaLanguages,
|
|
31
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import type { ProcaptchaRenderOptions } from "@prosopo/types";
|
|
16
|
+
|
|
17
|
+
export type RendererFunction = (
|
|
18
|
+
element: HTMLElement,
|
|
19
|
+
options: ProcaptchaRenderOptions,
|
|
20
|
+
) => Promise<void>;
|
|
21
|
+
|
|
22
|
+
export const loadRenderFunction = async (
|
|
23
|
+
scriptUrl: string,
|
|
24
|
+
scriptId: string,
|
|
25
|
+
): Promise<RendererFunction> => {
|
|
26
|
+
await loadScript(scriptUrl, {
|
|
27
|
+
id: scriptId,
|
|
28
|
+
type: "module",
|
|
29
|
+
async: true,
|
|
30
|
+
defer: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (undefined === window.procaptcha?.render) {
|
|
34
|
+
throw new Error("Render script does not contain the render function");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return window.procaptcha.render;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const loadScript = async (
|
|
41
|
+
url: string,
|
|
42
|
+
attributes?: Partial<HTMLScriptElement>,
|
|
43
|
+
): Promise<void> => {
|
|
44
|
+
const scriptTag = document.createElement("script");
|
|
45
|
+
|
|
46
|
+
const scriptAttributes: Partial<HTMLScriptElement> = {
|
|
47
|
+
src: url,
|
|
48
|
+
...attributes,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
Object.assign(scriptTag, scriptAttributes);
|
|
52
|
+
|
|
53
|
+
await insertScriptTag(document.head, scriptTag);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const insertScriptTag = async (
|
|
57
|
+
target: HTMLElement,
|
|
58
|
+
scriptTag: HTMLScriptElement,
|
|
59
|
+
): Promise<void> => {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
scriptTag.onload = () => {
|
|
62
|
+
resolve();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
scriptTag.onerror = (event: Event | string) => {
|
|
66
|
+
reject(event);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
target.appendChild(scriptTag);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
declare global {
|
|
74
|
+
interface Window {
|
|
75
|
+
procaptcha:
|
|
76
|
+
| {
|
|
77
|
+
render: RendererFunction;
|
|
78
|
+
}
|
|
79
|
+
| undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Copyright 2021-2026 Prosopo (UK) Ltd.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import type { ProcaptchaRenderOptions } from "@prosopo/types";
|
|
16
|
+
import { type RendererFunction, loadRenderFunction } from "./renderFunction.js";
|
|
17
|
+
|
|
18
|
+
interface RendererSettings {
|
|
19
|
+
scriptUrl: string;
|
|
20
|
+
scriptId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const createRenderer = (
|
|
24
|
+
settings: RendererSettings,
|
|
25
|
+
): RendererFunction => {
|
|
26
|
+
let renderFunction: RendererFunction;
|
|
27
|
+
|
|
28
|
+
const getRenderFunction = async (): Promise<RendererFunction> => {
|
|
29
|
+
if (!renderFunction) {
|
|
30
|
+
renderFunction = await loadRenderFunction(
|
|
31
|
+
settings.scriptUrl,
|
|
32
|
+
settings.scriptId,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return renderFunction;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return async (
|
|
40
|
+
element: HTMLElement,
|
|
41
|
+
options: ProcaptchaRenderOptions,
|
|
42
|
+
): Promise<void> => {
|
|
43
|
+
// cloning gives us a writable and independent object, which the render function then may change.
|
|
44
|
+
// reason: some frameworks, like React, lock extending, and direct operations lead to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_define_property_object_not_extensible
|
|
45
|
+
const renderOptions = Object.assign({}, options);
|
|
46
|
+
|
|
47
|
+
const renderFunction = await getRenderFunction();
|
|
48
|
+
|
|
49
|
+
await renderFunction(element, renderOptions);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.cjs.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist"
|
|
6
|
+
},
|
|
7
|
+
"include": ["./src"],
|
|
8
|
+
"references": [
|
|
9
|
+
{
|
|
10
|
+
"path": "../../dev/config/tsconfig.cjs.json"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"path": "../types/tsconfig.cjs.json"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "../locale/tsconfig.cjs.json"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.esm.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist"
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"./src",
|
|
9
|
+
"src/**/*.ts",
|
|
10
|
+
"src/**/*.tsx",
|
|
11
|
+
"src/**/*.json",
|
|
12
|
+
"src/**/*.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "../../dev/config/tsconfig.json"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "../types"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "../locale"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|