Skip to content

Commit 1d8b97c

Browse files
authored
feat: type declarations (#7)
1 parent a30aa52 commit 1d8b97c

File tree

10 files changed

+51
-34
lines changed

10 files changed

+51
-34
lines changed

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ public-hoist-pattern[]=*eslint*
22
public-hoist-pattern[]=*prettier*
33
public-hoist-pattern[]=@types*
44

5-
auto-install-peers=true
5+
auto-install-peers=true

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.16
1+
v18.16

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ const { response } = await hcaptcha.execute({ async: true });
3030
```
3131

3232
### Props
33-
|Name|Values/Type|Required|Default|Description|
34-
|---|---|---|---|---|
35-
|`loadAsync`|Boolean|No|`true`|Set if the script should be loaded asynchronously.|
36-
|`cleanup`|Boolean|No|`true`|Remove script tag after setup.|
37-
|`crossOrigin`|String|No|`-`|Set script cross origin attribute such as "anonymous".|
38-
|`scriptLocation`|HTMLElement|No|`document.head`| Location of where to append the script tag. Make sure to add it to an area that will persist to prevent loading multiple times in the same document view.|
39-
|`apihost`|String|No|`-`|See enterprise docs.|
40-
|`assethost`|String|No|`-`|See enterprise docs.|
41-
|`endpoint`|String|No|`-`|See enterprise docs.|
42-
|`host`|String|No|`-`|See enterprise docs.|
43-
|`imghost`|String|No|`-`|See enterprise docs.|
44-
|`reportapi`|String|No|`-`|See enterprise docs.|
45-
|`sentry`|Boolean|No|`-`|See enterprise docs.|
46-
|`custom`|Boolean|No|`-`|See enterprise docs.|
33+
| Name | Values/Type | Required | Default | Description |
34+
|------------------|-------------|----------|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
35+
| `loadAsync` | Boolean | No | `true` | Set if the script should be loaded asynchronously. |
36+
| `cleanup` | Boolean | No | `true` | Remove script tag after setup. |
37+
| `crossOrigin` | String | No | `-` | Set script cross origin attribute such as "anonymous". |
38+
| `scriptLocation` | HTMLElement | No | `document.head` | Location of where to append the script tag. Make sure to add it to an area that will persist to prevent loading multiple times in the same document view. |
39+
| `apihost` | String | No | `-` | See enterprise docs. |
40+
| `assethost` | String | No | `-` | See enterprise docs. |
41+
| `endpoint` | String | No | `-` | See enterprise docs. |
42+
| `host` | String | No | `-` | See enterprise docs. |
43+
| `imghost` | String | No | `-` | See enterprise docs. |
44+
| `reportapi` | String | No | `-` | See enterprise docs. |
45+
| `sentry` | Boolean | No | `-` | See enterprise docs. |
46+
| `custom` | Boolean | No | `-` | See enterprise docs. |

lib/esbuild.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const config = {
2525
bundle: true,
2626
entryPoints: [resolve(SRC, 'index.ts')],
2727
external: ['@hcaptcha/types'],
28-
tsconfig: './tsconfig.json',
28+
tsconfig: 'tsconfig.json',
2929
define: {
3030
'process.env.SENTRY_DSN_TOKEN': JSON.stringify(SENTRY),
3131

lib/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"type": "module",
55
"main": "src/index.ts",
66
"scripts": {
7-
"compile:build": "node ./esbuild.config.js",
7+
"compile:build": "rm -rf ../dist && node ./esbuild.config.js && tsc -p tsconfig.types.json",
88
"compile:watch": "WATCH=true node ./esbuild.config.js",
99
"fix:lint": "eslint -c .eslintrc.json --fix ./src",
1010
"test:lint": "eslint -c .eslintrc.json ./src",
11-
"test:types": "tsc --project ./tsconfig.json",
11+
"test:types": "tsc -p tsconfig.json",
1212
"test:unit": "jest"
1313
},
1414
"dependencies": {

lib/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { hCaptchaLoader } from './loader.js';
1+
export { hCaptchaLoader } from './loader';

lib/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
"compilerOptions": {
55
"target": "esnext",
66
"module": "esnext",
7-
"moduleResolution": "node"
7+
"moduleResolution": "node",
8+
"isolatedModules": true,
9+
"noEmit": true
810
},
9-
1011
"types": [
1112
"node",
1213
"jest",
1314
"@hcaptcha/types"
1415
],
1516

1617
"include": [
17-
"./jest.setup.ts",
1818
"./src/**/*"
1919
],
2020

lib/tsconfig.types.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
4+
"compilerOptions": {
5+
"target": "esnext",
6+
"module": "esnext",
7+
"moduleResolution": "node",
8+
"declaration": true,
9+
"isolatedModules": false,
10+
"emitDeclarationOnly": true,
11+
"outDir": "../dist/types"
12+
},
13+
14+
"include": [
15+
"src/**/*"
16+
]
17+
}

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@hcaptcha/loader",
33
"description": "This is a JavaScript library to easily configure the loading of the hCaptcha JS client SDK with built-in error handling.",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"author": "hCaptcha team and contributors",
66
"license": "MIT",
77
"keywords": [
@@ -10,28 +10,30 @@
1010
],
1111
"type": "module",
1212
"main": "dist/index.mjs",
13+
"types": "dist/types/src/index.d.ts",
1314
"exports": {
1415
"import": "dist/index.mjs",
15-
"require": "dis/index.cjs"
16+
"require": "dist/index.cjs"
1617
},
1718
"files": [
1819
"README.md",
19-
"dist"
20+
"dist",
21+
"!**/*.tsbuildinfo"
2022
],
2123
"repository": {
2224
"type": "git",
2325
"url": "https://github.com/hCaptcha/hcaptcha-loader.git"
2426
},
2527
"scripts": {
2628
"prepare": "pnpm run build:lib",
27-
"build:lib": "pnpm --filter @loader/lib run compile:build",
28-
"dev:lib": "pnpm --filter @loader/lib run compile:watch",
29+
"build:lib": "pnpm -r --stream run compile:build",
30+
"dev:lib": "pnpm -r --stream run compile:watch",
2931
"display:demo": "http-server ./ --cors -d -o ./demo/src",
3032
"serve:demo": "http-server ./",
31-
"fix:lint": "pnpm --filter @loader/* run fix:lint",
32-
"test:lint": "pnpm --filter @loader/* run test:lint",
33-
"test:types": "pnpm --filter @loader/* run test:types",
34-
"test:unit": "pnpm --filter @loader/lib run test:unit",
33+
"fix:lint": "pnpm -r --stream run fix:lint",
34+
"test:lint": "pnpm -r --stream run test:lint",
35+
"test:types": "pnpm -r --stream run test:types",
36+
"test:unit": "pnpm -r --stream run test:unit",
3537
"test:integration": "playwright test -c playwright.config.ts"
3638
},
3739
"devDependencies": {

tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"declaration": true,
66
"strict": false,
77
"allowJs": true,
8-
"noEmit": true,
98
"skipLibCheck": true,
109
"esModuleInterop": true,
1110
"incremental": true,
@@ -18,7 +17,6 @@
1817
"module": "nodenext",
1918
"moduleResolution": "nodenext",
2019
"resolveJsonModule": true,
21-
"isolatedModules": true,
2220

2321
"typeRoots": [
2422
"node_modules/@hcaptcha",

0 commit comments

Comments
 (0)