diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..08d01d434 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,25 @@ +{ + "mode": "pre", + "tag": "typescript", + "initialVersions": { + "@onflow/config": "1.2.0", + "@onflow/fcl": "1.6.0", + "@onflow/fcl-bundle": "1.4.0", + "@onflow/fcl-wc": "4.0.0", + "@onflow/protobuf": "1.2.1", + "@onflow/rlp": "1.2.0", + "@onflow/sdk": "1.3.0", + "@onflow/transport-grpc": "1.3.0", + "@onflow/transport-http": "1.8.0", + "@onflow/typedefs": "1.2.0", + "@onflow/types": "1.2.0", + "@onflow/util-actor": "1.3.0", + "@onflow/util-address": "1.2.0", + "@onflow/util-encode-key": "1.2.0", + "@onflow/util-invariant": "1.2.0", + "@onflow/util-logger": "1.3.0", + "@onflow/util-template": "1.2.0", + "@onflow/util-uid": "1.2.0" + }, + "changesets": [] +} diff --git a/package-lock.json b/package-lock.json index 60c5978ee..769513d33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,13 +9,24 @@ "./packages/*" ], "devDependencies": { - "@changesets/changelog-github": "^0.4.4", - "@changesets/cli": "^2.21.1", + "@babel/preset-typescript": "^7.22.5", + "@changesets/changelog-github": "^0.4.8", + "@changesets/cli": "^2.26.2", + "@types/jest": "^29.5.3", "@types/node": "^18.11.18", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "lerna": "^6.6.2", - "prettier": "^2.6.2" + "prettier": "^2.6.2", + "ts-jest": "^29.1.1" + } + }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "engines": { + "node": ">=0.10.0" } }, "node_modules/@ampproject/remapping": { @@ -163,18 +174,19 @@ "license": "ISC" }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.22.6", - "license": "MIT", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.22.9.tgz", + "integrity": "sha512-Pwyi89uO4YrGKxL/eNJ8lfEH55DnRloGPOseaA8NFNL6jAUnn+KccaISiFazCj5IolPPDjGSdzQzXVzODVRqUQ==", "dependencies": { "@babel/helper-annotate-as-pure": "^7.22.5", "@babel/helper-environment-visitor": "^7.22.5", "@babel/helper-function-name": "^7.22.5", "@babel/helper-member-expression-to-functions": "^7.22.5", "@babel/helper-optimise-call-expression": "^7.22.5", - "@babel/helper-replace-supers": "^7.22.5", + "@babel/helper-replace-supers": "^7.22.9", "@babel/helper-skip-transparent-expression-wrappers": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@nicolo-ribaudo/semver-v6": "^6.3.3" + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" @@ -183,6 +195,14 @@ "@babel/core": "^7.0.0" } }, + "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/helper-create-regexp-features-plugin": { "version": "7.21.0", "license": "MIT", @@ -328,18 +348,19 @@ } }, "node_modules/@babel/helper-replace-supers": { - "version": "7.22.5", - "license": "MIT", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.22.9.tgz", + "integrity": "sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==", "dependencies": { "@babel/helper-environment-visitor": "^7.22.5", "@babel/helper-member-expression-to-functions": "^7.22.5", - "@babel/helper-optimise-call-expression": "^7.22.5", - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/helper-optimise-call-expression": "^7.22.5" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-simple-access": { @@ -787,7 +808,6 @@ }, "node_modules/@babel/plugin-syntax-jsx": { "version": "7.22.5", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" @@ -887,7 +907,6 @@ }, "node_modules/@babel/plugin-syntax-typescript": { "version": "7.22.5", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" @@ -1347,6 +1366,23 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-typescript": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.22.9.tgz", + "integrity": "sha512-BnVR1CpKiuD0iobHPaM1iLvcwPYN2uVFAqoLVSpEDKWuOikoCv5HbKLxclhKYUXlWkX86DoZGtqI4XhbOsyrMg==", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.22.5", + "@babel/helper-create-class-features-plugin": "^7.22.9", + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/plugin-syntax-typescript": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-transform-unicode-escapes": { "version": "7.18.10", "license": "MIT", @@ -1482,6 +1518,24 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-typescript": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.22.5.tgz", + "integrity": "sha512-YbPaal9LxztSGhmndR46FmAbkJ/1fAsw293tSU+I5E5h+cnJ3d4GTwyUgGYmOXJYdGA+uNePle4qbaRzj2NISQ==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5", + "@babel/helper-validator-option": "^7.22.5", + "@babel/plugin-syntax-jsx": "^7.22.5", + "@babel/plugin-transform-modules-commonjs": "^7.22.5", + "@babel/plugin-transform-typescript": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/regjsgen": { "version": "0.8.0", "license": "MIT" @@ -1552,12 +1606,13 @@ "license": "MIT" }, "node_modules/@changesets/apply-release-plan": { - "version": "6.1.3", + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-6.1.4.tgz", + "integrity": "sha512-FMpKF1fRlJyCZVYHr3CbinpZZ+6MwvOtWUuO8uo+svcATEoc1zRDcj23pAurJ2TZ/uVz1wFHH6K3NlACy0PLew==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", - "@changesets/config": "^2.3.0", + "@changesets/config": "^2.3.1", "@changesets/get-version-range-type": "^0.3.2", "@changesets/git": "^2.0.0", "@changesets/types": "^5.2.1", @@ -1568,20 +1623,75 @@ "outdent": "^0.5.0", "prettier": "^2.7.1", "resolve-from": "^5.0.0", - "semver": "^5.4.1" + "semver": "^7.5.3" + } + }, + "node_modules/@changesets/apply-release-plan/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@changesets/apply-release-plan/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/@changesets/assemble-release-plan": { - "version": "5.2.3", + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/@changesets/assemble-release-plan/-/assemble-release-plan-5.2.4.tgz", + "integrity": "sha512-xJkWX+1/CUaOUWTguXEbCDTyWJFECEhmdtbkjhn5GVBGxdP/JwaHBIU9sW3FR6gD07UwZ7ovpiPclQZs+j+mvg==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", "@changesets/errors": "^0.1.4", - "@changesets/get-dependents-graph": "^1.3.5", + "@changesets/get-dependents-graph": "^1.3.6", "@changesets/types": "^5.2.1", "@manypkg/get-packages": "^1.1.3", - "semver": "^5.4.1" + "semver": "^7.5.3" + } + }, + "node_modules/@changesets/assemble-release-plan/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@changesets/assemble-release-plan/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/@changesets/changelog-git": { @@ -1603,18 +1713,19 @@ } }, "node_modules/@changesets/cli": { - "version": "2.26.0", + "version": "2.26.2", + "resolved": "https://registry.npmjs.org/@changesets/cli/-/cli-2.26.2.tgz", + "integrity": "sha512-dnWrJTmRR8bCHikJHl9b9HW3gXACCehz4OasrXpMp7sx97ECuBGGNjJhjPhdZNCvMy9mn4BWdplI323IbqsRig==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", - "@changesets/apply-release-plan": "^6.1.3", - "@changesets/assemble-release-plan": "^5.2.3", + "@changesets/apply-release-plan": "^6.1.4", + "@changesets/assemble-release-plan": "^5.2.4", "@changesets/changelog-git": "^0.1.14", - "@changesets/config": "^2.3.0", + "@changesets/config": "^2.3.1", "@changesets/errors": "^0.1.4", - "@changesets/get-dependents-graph": "^1.3.5", - "@changesets/get-release-plan": "^3.0.16", + "@changesets/get-dependents-graph": "^1.3.6", + "@changesets/get-release-plan": "^3.0.17", "@changesets/git": "^2.0.0", "@changesets/logger": "^0.0.5", "@changesets/pre": "^1.0.14", @@ -1623,7 +1734,7 @@ "@changesets/write": "^0.2.3", "@manypkg/get-packages": "^1.1.3", "@types/is-ci": "^3.0.0", - "@types/semver": "^6.0.0", + "@types/semver": "^7.5.0", "ansi-colors": "^4.1.3", "chalk": "^2.1.0", "enquirer": "^2.3.0", @@ -1636,7 +1747,7 @@ "p-limit": "^2.2.0", "preferred-pm": "^3.0.0", "resolve-from": "^5.0.0", - "semver": "^5.4.1", + "semver": "^7.5.3", "spawndamnit": "^2.0.0", "term-size": "^2.1.0", "tty-table": "^4.1.5" @@ -1645,13 +1756,41 @@ "changeset": "bin.js" } }, + "node_modules/@changesets/cli/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@changesets/cli/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@changesets/config": { - "version": "2.3.0", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@changesets/config/-/config-2.3.1.tgz", + "integrity": "sha512-PQXaJl82CfIXddUOppj4zWu+987GCw2M+eQcOepxN5s+kvnsZOwjEJO3DH9eVy+OP6Pg/KFEWdsECFEYTtbg6w==", "dev": true, - "license": "MIT", "dependencies": { "@changesets/errors": "^0.1.4", - "@changesets/get-dependents-graph": "^1.3.5", + "@changesets/get-dependents-graph": "^1.3.6", "@changesets/logger": "^0.0.5", "@changesets/types": "^5.2.1", "@manypkg/get-packages": "^1.1.3", @@ -1661,22 +1800,51 @@ }, "node_modules/@changesets/errors": { "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@changesets/errors/-/errors-0.1.4.tgz", + "integrity": "sha512-HAcqPF7snsUJ/QzkWoKfRfXushHTu+K5KZLJWPb34s4eCZShIf8BFO3fwq6KU8+G7L5KdtN2BzQAXOSXEyiY9Q==", "dev": true, - "license": "MIT", "dependencies": { "extendable-error": "^0.1.5" } }, "node_modules/@changesets/get-dependents-graph": { - "version": "1.3.5", + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/@changesets/get-dependents-graph/-/get-dependents-graph-1.3.6.tgz", + "integrity": "sha512-Q/sLgBANmkvUm09GgRsAvEtY3p1/5OCzgBE5vX3vgb5CvW0j7CEljocx5oPXeQSNph6FXulJlXV3Re/v3K3P3Q==", "dev": true, - "license": "MIT", "dependencies": { "@changesets/types": "^5.2.1", "@manypkg/get-packages": "^1.1.3", "chalk": "^2.1.0", "fs-extra": "^7.0.1", - "semver": "^5.4.1" + "semver": "^7.5.3" + } + }, + "node_modules/@changesets/get-dependents-graph/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@changesets/get-dependents-graph/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/@changesets/get-github-info": { @@ -1689,13 +1857,14 @@ } }, "node_modules/@changesets/get-release-plan": { - "version": "3.0.16", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/@changesets/get-release-plan/-/get-release-plan-3.0.17.tgz", + "integrity": "sha512-6IwKTubNEgoOZwDontYc2x2cWXfr6IKxP3IhKeK+WjyD6y3M4Gl/jdQvBw+m/5zWILSOCAaGLu2ZF6Q+WiPniw==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", - "@changesets/assemble-release-plan": "^5.2.3", - "@changesets/config": "^2.3.0", + "@changesets/assemble-release-plan": "^5.2.4", + "@changesets/config": "^2.3.1", "@changesets/pre": "^1.0.14", "@changesets/read": "^0.5.9", "@changesets/types": "^5.2.1", @@ -1704,13 +1873,15 @@ }, "node_modules/@changesets/get-version-range-type": { "version": "0.3.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/@changesets/get-version-range-type/-/get-version-range-type-0.3.2.tgz", + "integrity": "sha512-SVqwYs5pULYjYT4op21F2pVbcrca4qA/bAA3FmFXKMN7Y+HcO8sbZUTx3TAy2VXulP2FACd1aC7f2nTuqSPbqg==", + "dev": true }, "node_modules/@changesets/git": { "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@changesets/git/-/git-2.0.0.tgz", + "integrity": "sha512-enUVEWbiqUTxqSnmesyJGWfzd51PY4H7mH9yUw0hPVpZBJ6tQZFMU3F3mT/t9OJ/GjyiM4770i+sehAn6ymx6A==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", "@changesets/errors": "^0.1.4", @@ -1723,16 +1894,18 @@ }, "node_modules/@changesets/logger": { "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@changesets/logger/-/logger-0.0.5.tgz", + "integrity": "sha512-gJyZHomu8nASHpaANzc6bkQMO9gU/ib20lqew1rVx753FOxffnCrJlGIeQVxNWCqM+o6OOleCo/ivL8UAO5iFw==", "dev": true, - "license": "MIT", "dependencies": { "chalk": "^2.1.0" } }, "node_modules/@changesets/parse": { "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@changesets/parse/-/parse-0.3.16.tgz", + "integrity": "sha512-127JKNd167ayAuBjUggZBkmDS5fIKsthnr9jr6bdnuUljroiERW7FBTDNnNVyJ4l69PzR57pk6mXQdtJyBCJKg==", "dev": true, - "license": "MIT", "dependencies": { "@changesets/types": "^5.2.1", "js-yaml": "^3.13.1" @@ -1740,8 +1913,9 @@ }, "node_modules/@changesets/pre": { "version": "1.0.14", + "resolved": "https://registry.npmjs.org/@changesets/pre/-/pre-1.0.14.tgz", + "integrity": "sha512-dTsHmxQWEQekHYHbg+M1mDVYFvegDh9j/kySNuDKdylwfMEevTeDouR7IfHNyVodxZXu17sXoJuf2D0vi55FHQ==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", "@changesets/errors": "^0.1.4", @@ -1752,8 +1926,9 @@ }, "node_modules/@changesets/read": { "version": "0.5.9", + "resolved": "https://registry.npmjs.org/@changesets/read/-/read-0.5.9.tgz", + "integrity": "sha512-T8BJ6JS6j1gfO1HFq50kU3qawYxa4NTbI/ASNVVCBTsKquy2HYwM9r7ZnzkiMe8IEObAJtUVGSrePCOxAK2haQ==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.1", "@changesets/git": "^2.0.0", @@ -1826,13 +2001,36 @@ "node": "^14 || ^16 || ^17 || ^18 || ^19" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.2.tgz", + "integrity": "sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "2.0.0", - "license": "MIT", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", + "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -1849,11 +2047,13 @@ }, "node_modules/@eslint/eslintrc/node_modules/argparse": { "version": "2.0.1", - "license": "Python-2.0" + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dependencies": { "argparse": "^2.0.1" }, @@ -1862,8 +2062,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.35.0", - "license": "MIT", + "version": "8.47.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.47.0.tgz", + "integrity": "sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } @@ -1874,8 +2075,9 @@ "license": "MIT" }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "license": "Apache-2.0", + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", @@ -1898,7 +2100,8 @@ }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", - "license": "BSD-3-Clause" + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" }, "node_modules/@hutson/parse-repository-url": { "version": "3.0.2", @@ -3417,8 +3620,9 @@ }, "node_modules/@manypkg/find-root": { "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@manypkg/find-root/-/find-root-1.1.0.tgz", + "integrity": "sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.5.5", "@types/node": "^12.7.1", @@ -3428,13 +3632,15 @@ }, "node_modules/@manypkg/find-root/node_modules/@types/node": { "version": "12.20.55", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", + "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==", + "dev": true }, "node_modules/@manypkg/find-root/node_modules/fs-extra": { "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", "dev": true, - "license": "MIT", "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", @@ -3446,8 +3652,9 @@ }, "node_modules/@manypkg/get-packages": { "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@manypkg/get-packages/-/get-packages-1.1.3.tgz", + "integrity": "sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.5.5", "@changesets/types": "^4.0.1", @@ -3459,13 +3666,15 @@ }, "node_modules/@manypkg/get-packages/node_modules/@changesets/types": { "version": "4.1.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/@changesets/types/-/types-4.1.0.tgz", + "integrity": "sha512-LDQvVDv5Kb50ny2s25Fhm3d9QSZimsoUGBsUioj6MC3qbMUCuC8GPIvk/M6IvXx3lYhAs0lwWUQLb+VIEUCECw==", + "dev": true }, "node_modules/@manypkg/get-packages/node_modules/fs-extra": { "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", "dev": true, - "license": "MIT", "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", @@ -3543,13 +3752,6 @@ "tslib": "^2.3.1" } }, - "node_modules/@nicolo-ribaudo/semver-v6": { - "version": "6.3.3", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "license": "MIT", @@ -5028,6 +5230,16 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jest": { + "version": "29.5.3", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.3.tgz", + "integrity": "sha512-1Nq7YrO/vJE/FYnqYyw0FS8LdrjExSgIiHyKg7xPpn+yi8Q4huZryKnkJatN1ZRH89Kw2v33/8ZMB7DuZeSLlA==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, "node_modules/@types/jsdom": { "version": "20.0.1", "dev": true, @@ -5078,9 +5290,10 @@ "license": "MIT" }, "node_modules/@types/semver": { - "version": "6.2.3", - "dev": true, - "license": "MIT" + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true }, "node_modules/@types/stack-utils": { "version": "2.0.1", @@ -5109,51 +5322,321 @@ "dev": true, "license": "MIT" }, - "node_modules/@walletconnect/core": { - "version": "2.8.1", - "license": "Apache-2.0", + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.4.0.tgz", + "integrity": "sha512-62o2Hmc7Gs3p8SLfbXcipjWAa6qk2wZGChXG2JbBtYpwSRmti/9KHLqfbLs9uDigOexG+3PaQ9G2g3201FWLKg==", + "dev": true, "dependencies": { - "@walletconnect/heartbeat": "1.2.1", - "@walletconnect/jsonrpc-provider": "1.0.13", - "@walletconnect/jsonrpc-types": "1.0.3", - "@walletconnect/jsonrpc-utils": "1.0.8", - "@walletconnect/jsonrpc-ws-connection": "^1.0.11", - "@walletconnect/keyvaluestorage": "^1.0.2", - "@walletconnect/logger": "^2.0.1", - "@walletconnect/relay-api": "^1.0.9", - "@walletconnect/relay-auth": "^1.0.4", - "@walletconnect/safe-json": "^1.0.2", - "@walletconnect/time": "^1.0.2", - "@walletconnect/types": "2.8.1", - "@walletconnect/utils": "2.8.1", - "events": "^3.3.0", - "lodash.isequal": "4.5.0", - "uint8arrays": "^3.1.0" + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/type-utils": "6.4.0", + "@typescript-eslint/utils": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, - "node_modules/@walletconnect/core/node_modules/@walletconnect/safe-json": { - "version": "1.0.2", - "license": "MIT", + "node_modules/@typescript-eslint/eslint-plugin/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, "dependencies": { - "tslib": "1.14.1" + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" } }, - "node_modules/@walletconnect/core/node_modules/tslib": { - "version": "1.14.1", - "license": "0BSD" - }, - "node_modules/@walletconnect/environment": { - "version": "1.0.1", - "license": "MIT", + "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, "dependencies": { - "tslib": "1.14.1" + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, - "node_modules/@walletconnect/environment/node_modules/tslib": { - "version": "1.14.1", - "license": "0BSD" - }, - "node_modules/@walletconnect/events": { + "node_modules/@typescript-eslint/parser": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.0.tgz", + "integrity": "sha512-I1Ah1irl033uxjxO9Xql7+biL3YD7w9IU8zF+xlzD/YxY6a4b7DYA08PXUUCbm2sEljwJF6ERFy2kTGAGcNilg==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.4.0.tgz", + "integrity": "sha512-TUS7vaKkPWDVvl7GDNHFQMsMruD+zhkd3SdVW0d7b+7Zo+bd/hXJQ8nsiUZMi1jloWo6c9qt3B7Sqo+flC1nig==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.4.0.tgz", + "integrity": "sha512-TvqrUFFyGY0cX3WgDHcdl2/mMCWCDv/0thTtx/ODMY1QhEiyFtv/OlLaNIiYLwRpAxAtOLOY9SUf1H3Q3dlwAg==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/utils": "6.4.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.4.0.tgz", + "integrity": "sha512-+FV9kVFrS7w78YtzkIsNSoYsnOtrYVnKWSTVXoL1761CsCRv5wpDOINgsXpxD67YCLZtVQekDDyaxfjVWUJmmg==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.4.0.tgz", + "integrity": "sha512-iDPJArf/K2sxvjOR6skeUCNgHR/tCQXBsa+ee1/clRKr3olZjZ/dSkXPZjG6YkPtnW6p5D1egeEPMCW6Gn4yLA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.4.0.tgz", + "integrity": "sha512-BvvwryBQpECPGo8PwF/y/q+yacg8Hn/2XS+DqL/oRsOPK+RPt29h5Ui5dqOKHDlbXrAeHUTnyG3wZA0KTDxRZw==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.4.0.tgz", + "integrity": "sha512-yJSfyT+uJm+JRDWYRYdCm2i+pmvXJSMtPR9Cq5/XQs4QIgNoLcoRtDdzsLbLsFM/c6um6ohQkg/MLxWvoIndJA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.4.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@walletconnect/core": { + "version": "2.8.1", + "license": "Apache-2.0", + "dependencies": { + "@walletconnect/heartbeat": "1.2.1", + "@walletconnect/jsonrpc-provider": "1.0.13", + "@walletconnect/jsonrpc-types": "1.0.3", + "@walletconnect/jsonrpc-utils": "1.0.8", + "@walletconnect/jsonrpc-ws-connection": "^1.0.11", + "@walletconnect/keyvaluestorage": "^1.0.2", + "@walletconnect/logger": "^2.0.1", + "@walletconnect/relay-api": "^1.0.9", + "@walletconnect/relay-auth": "^1.0.4", + "@walletconnect/safe-json": "^1.0.2", + "@walletconnect/time": "^1.0.2", + "@walletconnect/types": "2.8.1", + "@walletconnect/utils": "2.8.1", + "events": "^3.3.0", + "lodash.isequal": "4.5.0", + "uint8arrays": "^3.1.0" + } + }, + "node_modules/@walletconnect/core/node_modules/@walletconnect/safe-json": { + "version": "1.0.2", + "license": "MIT", + "dependencies": { + "tslib": "1.14.1" + } + }, + "node_modules/@walletconnect/core/node_modules/tslib": { + "version": "1.14.1", + "license": "0BSD" + }, + "node_modules/@walletconnect/environment": { + "version": "1.0.1", + "license": "MIT", + "dependencies": { + "tslib": "1.14.1" + } + }, + "node_modules/@walletconnect/environment/node_modules/tslib": { + "version": "1.14.1", + "license": "0BSD" + }, + "node_modules/@walletconnect/events": { "version": "1.0.1", "license": "MIT", "dependencies": { @@ -5620,8 +6103,9 @@ } }, "node_modules/acorn": { - "version": "8.8.2", - "license": "MIT", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "bin": { "acorn": "bin/acorn" }, @@ -5648,7 +6132,8 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } @@ -5791,6 +6276,15 @@ "dev": true, "license": "ISC" }, + "node_modules/are-docs-informative": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/are-docs-informative/-/are-docs-informative-0.0.2.tgz", + "integrity": "sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/are-we-there-yet": { "version": "3.0.1", "dev": true, @@ -6129,8 +6623,9 @@ }, "node_modules/better-path-resolve": { "version": "1.0.0", + "resolved": "https://registry.npmjs.org/better-path-resolve/-/better-path-resolve-1.0.0.tgz", + "integrity": "sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==", "dev": true, - "license": "MIT", "dependencies": { "is-windows": "^1.0.0" }, @@ -6307,6 +6802,18 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/bser": { "version": "2.1.1", "dev": true, @@ -7747,8 +8254,9 @@ }, "node_modules/detect-indent": { "version": "6.1.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", + "integrity": "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==", "dev": true, - "license": "MIT", "engines": { "node": ">=8" } @@ -8155,24 +8663,26 @@ } }, "node_modules/eslint": { - "version": "8.35.0", - "license": "MIT", - "dependencies": { - "@eslint/eslintrc": "^2.0.0", - "@eslint/js": "8.35.0", - "@humanwhocodes/config-array": "^0.11.8", + "version": "8.47.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.47.0.tgz", + "integrity": "sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "^8.47.0", + "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -8180,23 +8690,19 @@ "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "bin": { @@ -8266,42 +8772,24 @@ } }, "node_modules/eslint-scope": { - "version": "7.1.1", - "license": "BSD-2-Clause", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "license": "Apache-2.0", - "engines": { - "node": ">=10" + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.1", - "license": "Apache-2.0", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -8455,12 +8943,13 @@ } }, "node_modules/espree": { - "version": "9.4.1", - "license": "BSD-2-Clause", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -8597,8 +9086,9 @@ }, "node_modules/extendable-error": { "version": "0.1.7", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/extendable-error/-/extendable-error-0.1.7.tgz", + "integrity": "sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==", + "dev": true }, "node_modules/external-editor": { "version": "3.1.0", @@ -8752,6 +9242,22 @@ "node": ">=0.10.0" } }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, "node_modules/find-up": { "version": "4.1.0", "license": "MIT", @@ -9560,8 +10066,9 @@ } }, "node_modules/globals": { - "version": "13.20.0", - "license": "MIT", + "version": "13.21.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", + "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", "dependencies": { "type-fest": "^0.20.2" }, @@ -9622,13 +10129,18 @@ }, "node_modules/graceful-fs": { "version": "4.2.10", - "dev": true, "license": "ISC" }, "node_modules/grapheme-splitter": { "version": "1.0.4", + "dev": true, "license": "MIT" }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==" + }, "node_modules/growly": { "version": "1.3.0", "dev": true, @@ -10475,8 +10987,9 @@ }, "node_modules/is-subdir": { "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-subdir/-/is-subdir-1.2.0.tgz", + "integrity": "sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==", "dev": true, - "license": "MIT", "dependencies": { "better-path-resolve": "1.0.0" }, @@ -10551,8 +11064,9 @@ }, "node_modules/is-windows": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", "dev": true, - "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -12328,14 +12842,6 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/js-sdsl": { - "version": "4.3.0", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/js-sdsl" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "license": "MIT" @@ -12959,7 +13465,8 @@ }, "node_modules/levn": { "version": "0.4.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dependencies": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" @@ -13411,14 +13918,21 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, "node_modules/lodash.merge": { "version": "4.6.2", "license": "MIT" }, "node_modules/lodash.startcase": { "version": "4.4.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/lodash.startcase/-/lodash.startcase-4.4.0.tgz", + "integrity": "sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==", + "dev": true }, "node_modules/log-symbols": { "version": "4.1.0", @@ -13530,7 +14044,6 @@ }, "node_modules/make-dir": { "version": "3.1.0", - "dev": true, "license": "MIT", "dependencies": { "semver": "^6.0.0" @@ -13544,7 +14057,6 @@ }, "node_modules/make-dir/node_modules/semver": { "version": "6.3.0", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -13553,9 +14065,7 @@ "node_modules/make-error": { "version": "1.3.6", "dev": true, - "license": "ISC", - "optional": true, - "peer": true + "license": "ISC" }, "node_modules/make-fetch-happen": { "version": "11.1.1", @@ -15115,15 +15625,16 @@ } }, "node_modules/optionator": { - "version": "0.9.1", - "license": "MIT", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "type-check": "^0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -15225,13 +15736,15 @@ }, "node_modules/outdent": { "version": "0.5.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/outdent/-/outdent-0.5.0.tgz", + "integrity": "sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==", + "dev": true }, "node_modules/p-filter": { "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-filter/-/p-filter-2.1.0.tgz", + "integrity": "sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==", "dev": true, - "license": "MIT", "dependencies": { "p-map": "^2.0.0" }, @@ -15241,8 +15754,9 @@ }, "node_modules/p-filter/node_modules/p-map": { "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", + "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==", "dev": true, - "license": "MIT", "engines": { "node": ">=6" } @@ -15788,7 +16302,6 @@ }, "node_modules/pkg-dir": { "version": "4.2.0", - "dev": true, "license": "MIT", "dependencies": { "find-up": "^4.0.0" @@ -15907,7 +16420,8 @@ }, "node_modules/prelude-ls": { "version": "1.2.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "engines": { "node": ">= 0.8.0" } @@ -16049,8 +16563,9 @@ }, "node_modules/pseudomap": { "version": "1.0.2", - "dev": true, - "license": "ISC" + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==", + "dev": true }, "node_modules/psl": { "version": "1.9.0", @@ -16495,8 +17010,9 @@ }, "node_modules/read-yaml-file": { "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-yaml-file/-/read-yaml-file-1.1.0.tgz", + "integrity": "sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==", "dev": true, - "license": "MIT", "dependencies": { "graceful-fs": "^4.1.5", "js-yaml": "^3.6.1", @@ -16509,16 +17025,18 @@ }, "node_modules/read-yaml-file/node_modules/pify": { "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", "dev": true, - "license": "MIT", "engines": { "node": ">=6" } }, "node_modules/read-yaml-file/node_modules/strip-bom": { "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true, - "license": "MIT", "engines": { "node": ">=4" } @@ -16606,16 +17124,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexpp": { - "version": "3.2.0", - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/regexpu-core": { "version": "5.3.1", "license": "MIT", @@ -16777,6 +17285,91 @@ "fsevents": "~2.3.2" } }, + "node_modules/rollup-plugin-typescript2": { + "version": "0.35.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.35.0.tgz", + "integrity": "sha512-szcIO9hPUx3PhQl91u4pfNAH2EKbtrXaES+m163xQVE5O1CC0ea6YZV/5woiDDW3CR9jF2CszPrKN+AFiND0bg==", + "dependencies": { + "@rollup/pluginutils": "^4.1.2", + "find-cache-dir": "^3.3.2", + "fs-extra": "^10.0.0", + "semver": "^7.3.7", + "tslib": "^2.4.0" + }, + "peerDependencies": { + "rollup": ">=1.26.3", + "typescript": ">=2.4.0" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/run-async": { "version": "2.4.1", "dev": true, @@ -17207,8 +17800,9 @@ }, "node_modules/spawndamnit": { "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spawndamnit/-/spawndamnit-2.0.0.tgz", + "integrity": "sha512-j4JKEcncSjFlqIwU5L/rp2N5SIPsdxaRsIv678+TZxZ0SRDJTm8JrxJMjE/XuiEZNEir3S8l0Fa3Ke339WI4qA==", "dev": true, - "license": "MIT", "dependencies": { "cross-spawn": "^5.1.0", "signal-exit": "^3.0.2" @@ -17216,8 +17810,9 @@ }, "node_modules/spawndamnit/node_modules/cross-spawn": { "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==", "dev": true, - "license": "MIT", "dependencies": { "lru-cache": "^4.0.1", "shebang-command": "^1.2.0", @@ -17226,8 +17821,9 @@ }, "node_modules/spawndamnit/node_modules/lru-cache": { "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "dev": true, - "license": "ISC", "dependencies": { "pseudomap": "^1.0.2", "yallist": "^2.1.2" @@ -17235,8 +17831,9 @@ }, "node_modules/spawndamnit/node_modules/shebang-command": { "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", "dev": true, - "license": "MIT", "dependencies": { "shebang-regex": "^1.0.0" }, @@ -17246,16 +17843,18 @@ }, "node_modules/spawndamnit/node_modules/shebang-regex": { "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", "dev": true, - "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/spawndamnit/node_modules/which": { "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, - "license": "ISC", "dependencies": { "isexe": "^2.0.0" }, @@ -17265,8 +17864,9 @@ }, "node_modules/spawndamnit/node_modules/yallist": { "version": "2.1.2", - "dev": true, - "license": "ISC" + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", + "dev": true }, "node_modules/spdx-correct": { "version": "3.2.0", @@ -17827,6 +18427,97 @@ "node": ">=8" } }, + "node_modules/ts-api-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.1.tgz", + "integrity": "sha512-lC/RGlPmwdrIBFTX59wwNzqh7aR2otPNPR/5brHZm/XKFYKsfqxihXUe9pU3JI+3vGkl+vyCoNNnPhJn3aLK1A==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, + "node_modules/ts-jest": { + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", + "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "dev": true, + "dependencies": { + "bs-logger": "0.x", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "^7.5.3", + "yargs-parser": "^21.0.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-jest/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/ts-node": { "version": "10.9.1", "dev": true, @@ -18073,7 +18764,8 @@ }, "node_modules/type-check": { "version": "0.4.0", - "license": "MIT", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dependencies": { "prelude-ls": "^1.2.1" }, @@ -18091,7 +18783,8 @@ }, "node_modules/type-fest": { "version": "0.20.2", - "license": "(MIT OR CC0-1.0)", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "engines": { "node": ">=10" }, @@ -18119,7 +18812,6 @@ }, "node_modules/typescript": { "version": "4.9.5", - "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -18557,6 +19249,7 @@ }, "node_modules/word-wrap": { "version": "1.2.3", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -18858,16 +19551,16 @@ }, "packages/config": { "name": "@onflow/config", - "version": "1.1.1-alpha.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-actor": "^1.2.0", + "@onflow/util-actor": "^1.3.0-alpha.0", "eslint": "^8.34.0", "eslint-plugin-jsdoc": "^40.0.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/estree": "^1.0.1", "jest": "^29.5.0", "typescript": "^4.9.5" @@ -18927,26 +19620,26 @@ }, "packages/fcl": { "name": "@onflow/fcl", - "version": "1.5.0-alpha.3", + "version": "1.6.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1-alpha.0", + "@onflow/config": "^1.2.0-alpha.0", "@onflow/interaction": "0.0.11", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.1-alpha.0", - "@onflow/types": "^1.1.0", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1-alpha.0", - "@onflow/util-template": "^1.1.0", - "@onflow/util-uid": "^1.1.0", + "@onflow/rlp": "^1.2.0-alpha.0", + "@onflow/sdk": "^1.3.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", + "@onflow/util-actor": "^1.3.0-alpha.0", + "@onflow/util-address": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-logger": "^1.3.0-alpha.0", + "@onflow/util-template": "^1.2.0-alpha.0", + "@onflow/util-uid": "^1.2.0-alpha.0", "cross-fetch": "^3.1.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/typedefs": "^1.1.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/typedefs": "^1.2.0-alpha.0", "@types/node": "^18.13.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", @@ -18981,11 +19674,12 @@ }, "packages/fcl-bundle": { "name": "@onflow/fcl-bundle", - "version": "1.3.1-alpha.0", + "version": "1.4.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/plugin-transform-runtime": "^7.18.2", "@babel/preset-env": "^7.18.2", + "@babel/preset-typescript": "^7.22.5", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.2", "@rollup/plugin-node-resolve": "^15.1.0", @@ -18994,7 +19688,8 @@ "builtin-modules": "^3.3.0", "commander": "^9.3.0", "lodash": "^4.17.21", - "rollup": "^2.75.5" + "rollup": "^2.75.5", + "rollup-plugin-typescript2": "^0.35.0" }, "bin": { "fcl-bundle": "src/cli.js" @@ -19009,25 +19704,25 @@ }, "packages/fcl-wc": { "name": "@onflow/fcl-wc", - "version": "3.0.0-alpha.2", + "version": "4.0.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.9", - "@onflow/config": "^1.1.1-alpha.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1-alpha.0", + "@onflow/config": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-logger": "^1.3.0-alpha.0", "@walletconnect/modal": "^2.4.7", "@walletconnect/sign-client": "^2.8.1", "@walletconnect/types": "^2.8.1", "@walletconnect/utils": "^2.8.1" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "better-sqlite3": "^7.6.2", "jest": "^29.5.0" }, "peerDependencies": { - "@onflow/fcl": "^1.5.0-alpha.3" + "@onflow/fcl": "^1.6.0-alpha.0" } }, "packages/fcl/node_modules/eslint-plugin-jsdoc": { @@ -19088,7 +19783,7 @@ }, "packages/protobuf": { "name": "@onflow/protobuf", - "version": "1.2.1-alpha.0", + "version": "1.2.1", "license": "Apache-2.0", "dependencies": { "@improbable-eng/grpc-web": "^0.12.0", @@ -19554,37 +20249,137 @@ }, "packages/rlp": { "name": "@onflow/rlp", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "MPL-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "buffer": "^6.0.3" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, + "packages/rlp/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/rlp/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/rlp/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/rlp/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/rlp/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/rlp/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/rlp/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/sdk": { "name": "@onflow/sdk", - "version": "1.2.1-alpha.0", + "version": "1.3.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1-alpha.0", - "@onflow/rlp": "^1.1.0", - "@onflow/transport-http": "^1.7.0-alpha.0", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1-alpha.0", - "@onflow/util-template": "^1.1.0", + "@onflow/config": "^1.2.0-alpha.0", + "@onflow/rlp": "^1.2.0-alpha.0", + "@onflow/transport-http": "^1.8.0-alpha.0", + "@onflow/util-actor": "^1.3.0-alpha.0", + "@onflow/util-address": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-logger": "^1.3.0-alpha.0", + "@onflow/util-template": "^1.2.0-alpha.0", "deepmerge": "^4.2.2", "sha3": "^2.1.4" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/typedefs": "^1.1.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/typedefs": "^1.2.0-alpha.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", @@ -19649,21 +20444,21 @@ }, "packages/transport-grpc": { "name": "@onflow/transport-grpc", - "version": "1.2.1-alpha.0", + "version": "1.3.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", "@improbable-eng/grpc-web": "^0.14.0", "@improbable-eng/grpc-web-node-http-transport": "^0.14.0", - "@onflow/protobuf": "^1.2.1-alpha.0", - "@onflow/rlp": "^1.1.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-template": "^1.1.0" + "@onflow/protobuf": "^1.2.1", + "@onflow/rlp": "^1.2.0-alpha.0", + "@onflow/util-address": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-template": "^1.2.0-alpha.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/sdk": "^1.2.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/sdk": "^1.3.0-alpha.0", "jest": "^29.5.0" } }, @@ -19691,34 +20486,34 @@ }, "packages/transport-http": { "name": "@onflow/transport-http", - "version": "1.7.0-alpha.0", + "version": "1.8.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1-alpha.0", - "@onflow/util-template": "^1.1.0", + "@onflow/util-address": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0", + "@onflow/util-logger": "^1.3.0-alpha.0", + "@onflow/util-template": "^1.2.0-alpha.0", "abort-controller": "^3.0.0", "cross-fetch": "^3.1.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.1-alpha.0", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/rlp": "^1.2.0-alpha.0", + "@onflow/sdk": "^1.3.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", "jest": "^29.5.0" } }, "packages/typedefs": { "name": "@onflow/typedefs", - "version": "1.1.1-alpha.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", "@types/node": "^18.13.0", "eslint": "^8.33.0", "eslint-plugin-jsdoc": "^39.7.5", @@ -19729,114 +20524,919 @@ }, "packages/types": { "name": "@onflow/types", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.18.6" + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0-alpha.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, - "packages/util-actor": { - "name": "@onflow/util-actor", - "version": "1.2.0", - "license": "Apache-2.0", + "packages/types/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, "dependencies": { - "@babel/runtime": "^7.18.6", - "queue-microtask": "1.2.3" + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "jest": "^29.5.0" + "engines": { + "node": ">=16" } }, - "packages/util-address": { - "name": "@onflow/util-address", - "version": "1.1.0", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime": "^7.18.6" - }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", - "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.7.5", - "jest": "^29.5.0", - "typescript": "^4.9.5" + "packages/types/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" } }, - "packages/util-encode-key": { - "name": "@onflow/util-encode-key", - "version": "1.1.0", - "license": "Apache-2.0", - "dependencies": { - "@babel/runtime": "^7.18.6", - "@onflow/rlp": "^1.1.0", - "@onflow/util-invariant": "^1.1.0" + "packages/types/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", - "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.8.0", - "jest": "^29.5.0", - "typescript": "^4.9.5" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/util-invariant": { - "name": "@onflow/util-invariant", - "version": "1.1.0", - "license": "Apache-2.0", + "packages/types/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, "dependencies": { - "@babel/runtime": "^7.18.6" - }, - "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/types/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/types/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/types/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-actor": { + "name": "@onflow/util-actor", + "version": "1.3.0-alpha.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6", + "queue-microtask": "1.2.3" + }, + "devDependencies": { + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", + "jest": "^29.5.0" + } + }, + "packages/util-actor/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-actor/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-actor/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-actor/node_modules/eslint-plugin-jsdoc": { + "version": "46.5.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.5.1.tgz", + "integrity": "sha512-CPbvKprmEuJYoxMj5g8gXfPqUGgcqMM6jpH06Kp4pn5Uy5MrPkFKzoD7UFp2E4RBzfXbJz1+TeuEivwFVMkXBg==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-actor/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-actor/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-actor/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-address": { + "name": "@onflow/util-address", + "version": "1.2.0-alpha.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6" + }, + "devDependencies": { + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", + "@types/jest": "^29.5.3", + "@types/node": "^18.13.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", + "jest": "^29.5.0", + "typescript": "^4.9.5" + } + }, + "packages/util-address/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-address/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-address/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-address/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-address/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-address/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-address/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-encode-key": { + "name": "@onflow/util-encode-key", + "version": "1.2.0-alpha.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6", + "@onflow/rlp": "^1.2.0-alpha.0", + "@onflow/util-invariant": "^1.2.0-alpha.0" + }, + "devDependencies": { + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", + "@types/jest": "^29.5.3", + "@types/node": "^18.13.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", + "jest": "^29.5.0", + "typescript": "^4.9.5" + } + }, + "packages/util-encode-key/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-encode-key/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-encode-key/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-encode-key/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-encode-key/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-encode-key/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-encode-key/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-invariant": { + "name": "@onflow/util-invariant", + "version": "1.2.0-alpha.0", + "license": "Apache-2.0", + "dependencies": { + "@babel/runtime": "^7.18.6" + }, + "devDependencies": { + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@onflow/types": "^1.2.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, + "packages/util-invariant/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-invariant/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-invariant/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-invariant/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-invariant/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-invariant/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-invariant/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/util-logger": { "name": "@onflow/util-logger", - "version": "1.2.1-alpha.0", + "version": "1.3.0-alpha.0", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1-alpha.0" + "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" + }, + "peerDependencies": { + "@onflow/util-config": ">1.1.1" + }, + "peerDependenciesMeta": { + "@onflow/util-config": { + "optional": true + } + } + }, + "packages/util-logger/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-logger/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-logger/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-logger/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-logger/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-logger/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-logger/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "packages/util-template": { "name": "@onflow/util-template", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { - "@babel/runtime": "^7.18.6" + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0-alpha.0" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } }, + "packages/util-template/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-template/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-template/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-template/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-template/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-template/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-template/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/util-uid": { "name": "@onflow/util-uid", - "version": "1.1.0", + "version": "1.2.0-alpha.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.18.6" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0-alpha.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" } + }, + "packages/util-uid/node_modules/@es-joy/jsdoccomment": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.40.1.tgz", + "integrity": "sha512-YORCdZSusAlBrFpZ77pJjc5r1bQs5caPWtAu+WWmiSo+8XaUzseapVrfAtiRFbQWnrBxxLLEwF6f6ZG/UgCQCg==", + "dev": true, + "dependencies": { + "comment-parser": "1.4.0", + "esquery": "^1.5.0", + "jsdoc-type-pratt-parser": "~4.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "packages/util-uid/node_modules/comment-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.0.tgz", + "integrity": "sha512-QLyTNiZ2KDOibvFPlZ6ZngVsZ/0gYnE6uTXi5aoDg8ed3AkJAz4sEje3Y8a29hQ1s6A99MZXe47fLAXQ1rTqaw==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, + "packages/util-uid/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/util-uid/node_modules/eslint-plugin-jsdoc": { + "version": "46.4.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-46.4.6.tgz", + "integrity": "sha512-z4SWYnJfOqftZI+b3RM9AtWL1vF/sLWE/LlO9yOKDof9yN2+n3zOdOJTGX/pRE/xnPsooOLG2Rq6e4d+XW3lNw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.40.1", + "are-docs-informative": "^0.0.2", + "comment-parser": "1.4.0", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.5.0", + "is-builtin-module": "^3.2.1", + "semver": "^7.5.4", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "packages/util-uid/node_modules/jsdoc-type-pratt-parser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz", + "integrity": "sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/util-uid/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "packages/util-uid/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } } } } diff --git a/package.json b/package.json index 7bfe3842e..a2f959e10 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "./packages/*" ], "scripts": { - "build": "lerna run build:types && lerna run build", + "build": "lerna run build", "start": "npm run build && lerna run start --parallel", "test": "jest", "release": "npm run build && npm run changeset publish", @@ -11,12 +11,15 @@ }, "name": "fcl-js", "devDependencies": { - "@changesets/changelog-github": "^0.4.4", - "@changesets/cli": "^2.21.1", + "@babel/preset-typescript": "^7.22.5", + "@changesets/changelog-github": "^0.4.8", + "@changesets/cli": "^2.26.2", + "@types/jest": "^29.5.3", "@types/node": "^18.11.18", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "lerna": "^6.6.2", - "prettier": "^2.6.2" + "prettier": "^2.6.2", + "ts-jest": "^29.1.1" } } diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index b15da29f7..0b3210483 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,27 @@ # @onflow/config +## 1.2.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`92b966d3`](https://github.com/onflow/fcl-js/commit/92b966d39936ba0a90629ee320e62e4fed5d2296)]: + - @onflow/util-actor@1.3.0 + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + +### Patch Changes + +- Updated dependencies []: + - @onflow/util-actor@1.3.0-alpha.0 + ## 1.1.2 ### Patch Changes diff --git a/packages/config/package.json b/packages/config/package.json index 2dd2ebbc1..e2c4902da 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/config", - "version": "1.1.2", + "version": "1.2.0", "description": "Config for FCL-JS", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,7 +13,7 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0", "@types/estree": "^1.0.1", "jest": "^29.5.0", "typescript": "^4.9.5" @@ -26,15 +26,14 @@ "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", - "build": "npm run lint && fcl-bundle", - "build:types": "tsc", + "build": "tsc && npm run lint && fcl-bundle", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-actor": "^1.2.0", + "@onflow/util-actor": "^1.3.0", "eslint": "^8.34.0", "eslint-plugin-jsdoc": "^40.0.0" } diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index ef17eba8e..ac6917898 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -1,24 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, + "outDir": "types" } -} \ No newline at end of file +} diff --git a/packages/fcl-bundle/CHANGELOG.md b/packages/fcl-bundle/CHANGELOG.md index b182bc8e7..4bc70f1a1 100644 --- a/packages/fcl-bundle/CHANGELOG.md +++ b/packages/fcl-bundle/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/fcl-bundle +## 1.4.0 + +### Minor Changes + +- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Switched to rollup-plugin-typescript2 + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +## 1.4.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.3.1 ### Patch Changes diff --git a/packages/fcl-bundle/package.json b/packages/fcl-bundle/package.json index 8da987fa7..2598910f8 100644 --- a/packages/fcl-bundle/package.json +++ b/packages/fcl-bundle/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/fcl-bundle", - "version": "1.3.1", + "version": "1.4.0", "description": "FCL Bundler Tool", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -15,6 +15,7 @@ "dependencies": { "@babel/plugin-transform-runtime": "^7.18.2", "@babel/preset-env": "^7.18.2", + "@babel/preset-typescript": "^7.22.5", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.2", "@rollup/plugin-node-resolve": "^15.1.0", @@ -23,7 +24,8 @@ "builtin-modules": "^3.3.0", "commander": "^9.3.0", "lodash": "^4.17.21", - "rollup": "^2.75.5" + "rollup": "^2.75.5", + "rollup-plugin-typescript2": "^0.35.0" }, "bin": { "fcl-bundle": "src/cli.js" diff --git a/packages/fcl-bundle/src/build/get-input-options.js b/packages/fcl-bundle/src/build/get-input-options.js index e3906a391..b84ffe284 100644 --- a/packages/fcl-bundle/src/build/get-input-options.js +++ b/packages/fcl-bundle/src/build/get-input-options.js @@ -4,7 +4,9 @@ const commonjs = require("@rollup/plugin-commonjs") const replace = require("@rollup/plugin-replace") const {nodeResolve} = require("@rollup/plugin-node-resolve") const {babel} = require("@rollup/plugin-babel") -const terser = require('@rollup/plugin-terser') +const terser = require("@rollup/plugin-terser") +const typescript = require("rollup-plugin-typescript2") +const {DEFAULT_EXTENSIONS} = require("@babel/core") const builtinModules = require("builtin-modules") @@ -15,12 +17,17 @@ const SUPPRESSED_WARNING_CODES = [ ] module.exports = function getInputOptions(package, build) { + // ensure that that package has the required dependencies if (!package.dependencies["@babel/runtime"]) { throw new Error( `${package.name} is missing required @babel/runtime dependency. Please add this to the package.json and try again.` ) } + // determine if we are building typescript + const source = build.source + const isTypeScript = source.endsWith(".ts") + const babelRuntimeVersion = package.dependencies["@babel/runtime"].replace( /^[^0-9]*/, "" @@ -43,7 +50,11 @@ module.exports = function getInputOptions(package, build) { }, false)) // exclude peer dependencies - const resolveOnly = [new RegExp(`^(?!${Object.keys(package.peerDependencies || {}).join("|")}).*`)] + const resolveOnly = [ + new RegExp( + `^(?!${Object.keys(package.peerDependencies || {}).join("|")}).*` + ), + ] let options = { input: build.source, @@ -53,19 +64,23 @@ module.exports = function getInputOptions(package, build) { console.warn(message.toString()) }, plugins: [ - replace({ - preventAssignment: true, - PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), - }), - commonjs(), nodeResolve({ browser: true, preferBuiltins: build.type !== "umd", resolveOnly, }), + commonjs(), + isTypeScript && + typescript({ + clean: true, + }), + replace({ + preventAssignment: true, + PACKAGE_CURRENT_VERSION: JSON.stringify(package.version), + }), babel({ babelHelpers: "runtime", - presets: [["@babel/preset-env"]], + presets: ["@babel/preset-env", "@babel/preset-typescript"], plugins: [ [ "@babel/plugin-transform-runtime", @@ -75,6 +90,7 @@ module.exports = function getInputOptions(package, build) { ], ], sourceMaps: true, + extensions: [...DEFAULT_EXTENSIONS, ".ts", ".tsx"], }), /\.min\.js$/.test(build.entry) && terser({ diff --git a/packages/fcl-bundle/tsconfig.json b/packages/fcl-bundle/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/fcl-bundle/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/fcl-wc/CHANGELOG.md b/packages/fcl-wc/CHANGELOG.md index 612d3c282..07991fac2 100644 --- a/packages/fcl-wc/CHANGELOG.md +++ b/packages/fcl-wc/CHANGELOG.md @@ -2,6 +2,34 @@ ## 4.0.0 +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477)]: + - @onflow/util-invariant@1.2.0 + - @onflow/util-logger@1.3.0 + - @onflow/config@1.2.0 + - @onflow/fcl@1.6.0 + +## 4.0.0-alpha.0 + +### Minor Changes + +- TS build + +### Patch Changes + +- Updated dependencies []: + - @onflow/util-invariant@1.2.0-alpha.0 + - @onflow/util-logger@1.3.0-alpha.0 + - @onflow/config@1.2.0-alpha.0 + - @onflow/fcl@1.6.0-alpha.0 + +## 4.0.0 + ### Patch Changes - Updated dependencies [[`3c99c856`](https://github.com/onflow/fcl-js/commit/3c99c8560f61b5b38238cbd0e93814936aee282e), [`5edbd823`](https://github.com/onflow/fcl-js/commit/5edbd823b1a6d25eb7bb52dc55338f95beae73b1)]: diff --git a/packages/fcl-wc/package.json b/packages/fcl-wc/package.json index b2bce4dd5..692093649 100644 --- a/packages/fcl-wc/package.json +++ b/packages/fcl-wc/package.json @@ -25,15 +25,15 @@ "start": "fcl-bundle --watch" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0", "better-sqlite3": "^7.6.2", "jest": "^29.5.0" }, "dependencies": { "@babel/runtime": "^7.18.9", - "@onflow/config": "^1.1.2", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", + "@onflow/config": "^1.2.0", + "@onflow/util-invariant": "^1.2.0", + "@onflow/util-logger": "^1.3.0", "@walletconnect/modal": "^2.4.7", "@walletconnect/sign-client": "^2.8.1", "@walletconnect/types": "^2.8.1", diff --git a/packages/fcl-wc/tsconfig.json b/packages/fcl-wc/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/fcl-wc/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/fcl/CHANGELOG.md b/packages/fcl/CHANGELOG.md index 9dcb3b080..124007170 100644 --- a/packages/fcl/CHANGELOG.md +++ b/packages/fcl/CHANGELOG.md @@ -4,6 +4,46 @@ ### Minor Changes +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`0e4a4b1a`](https://github.com/onflow/fcl-js/commit/0e4a4b1aa4d9d18b9f8c2fa1e9db1b8e6ab9b15a), [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477), [`92b966d3`](https://github.com/onflow/fcl-js/commit/92b966d39936ba0a90629ee320e62e4fed5d2296)]: + - @onflow/types@1.2.0 + - @onflow/util-invariant@1.2.0 + - @onflow/util-template@1.2.0 + - @onflow/util-address@1.2.0 + - @onflow/util-logger@1.3.0 + - @onflow/util-actor@1.3.0 + - @onflow/util-uid@1.2.0 + - @onflow/config@1.2.0 + - @onflow/rlp@1.2.0 + - @onflow/sdk@1.3.0 + +## 1.6.0-alpha.0 + +### Minor Changes + +- TS build + +### Patch Changes + +- Updated dependencies []: + - @onflow/util-invariant@1.2.0-alpha.0 + - @onflow/util-template@1.2.0-alpha.0 + - @onflow/util-address@1.2.0-alpha.0 + - @onflow/util-logger@1.3.0-alpha.0 + - @onflow/util-actor@1.3.0-alpha.0 + - @onflow/util-uid@1.2.0-alpha.0 + - @onflow/config@1.2.0-alpha.0 + - @onflow/types@1.2.0-alpha.0 + - @onflow/rlp@1.2.0-alpha.0 + - @onflow/sdk@1.3.0-alpha.0 + +## 1.6.0 + +### Minor Changes + - [#1763](https://github.com/onflow/fcl-js/pull/1763) [`3c99c856`](https://github.com/onflow/fcl-js/commit/3c99c8560f61b5b38238cbd0e93814936aee282e) Thanks [@jribbink](https://github.com/jribbink)! - Add VIEW/DEEPLINK ### Patch Changes diff --git a/packages/fcl/package.json b/packages/fcl/package.json index f81994819..b1ba0d5ee 100644 --- a/packages/fcl/package.json +++ b/packages/fcl/package.json @@ -19,8 +19,8 @@ } }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/typedefs": "^1.1.1", + "@onflow/fcl-bundle": "^1.4.0", + "@onflow/typedefs": "^1.2.0", "@types/node": "^18.13.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", @@ -29,12 +29,12 @@ "typescript": "^4.9.5" }, "source": { - "src/fcl.js": { + "src/fcl.ts": { "cjs": "./dist/fcl.js", "esm": "./dist/fcl.module.js", "umd": "./dist/fcl.umd.min.js" }, - "src/fcl-react-native.js": { + "src/fcl-react-native.ts": { "cjs": "./dist/fcl-react-native.js", "esm": "./dist/fcl-react-native.module.js", "umd": "./dist/fcl-react-native.umd.min.js" @@ -57,17 +57,17 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.2", + "@onflow/config": "^1.2.0", "@onflow/interaction": "0.0.11", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.2", - "@onflow/types": "^1.1.0", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.2", - "@onflow/util-template": "^1.1.0", - "@onflow/util-uid": "^1.1.0", + "@onflow/rlp": "^1.2.0", + "@onflow/sdk": "^1.3.0", + "@onflow/types": "^1.2.0", + "@onflow/util-actor": "^1.3.0", + "@onflow/util-address": "^1.2.0", + "@onflow/util-invariant": "^1.2.0", + "@onflow/util-logger": "^1.3.0", + "@onflow/util-template": "^1.2.0", + "@onflow/util-uid": "^1.2.0", "cross-fetch": "^3.1.6" }, "peerDependencies": { diff --git a/packages/fcl/src/current-user/index.js b/packages/fcl/src/current-user/index.js index a33dff0eb..3a7e74edd 100644 --- a/packages/fcl/src/current-user/index.js +++ b/packages/fcl/src/current-user/index.js @@ -149,81 +149,83 @@ const makeConfig = async ({discoveryAuthnInclude}) => { * @param {object} [opts.platform] - platform that runs the function * @param {object} [opts.service] - Optional service to use for authentication * @param {boolean} [opts.redir=false] - Optional flag to allow window to stay open after authentication - * @returns {Promise} - User object + * @returns {function(*)Promise} - User object */ -const getAuthenticate = ({platform}) => async ({service, redir = false} = {}) => { - if ( - service && - !service?.provider?.is_installed && - service?.provider?.requires_install - ) { - window.location.href = service?.provider?.install_link - return - } +const getAuthenticate = + ({platform}) => + async ({service, redir = false} = {}) => { + if ( + service && + !service?.provider?.is_installed && + service?.provider?.requires_install + ) { + window.location.href = service?.provider?.install_link + return + } - return new Promise(async (resolve, reject) => { - spawnCurrentUser() - const opts = {redir} - const user = await snapshot() - const discoveryService = await getDiscoveryService(service) - const refreshService = serviceOfType(user.services, "authn-refresh") - let accountProofData - - if (user.loggedIn) { - if (refreshService) { - try { - const response = await execService({ - service: refreshService, - msg: accountProofData, - opts, - platform, - }) - send(NAME, SET_CURRENT_USER, await buildUser(response)) - } catch (error) { - log({ - title: `${error.name} Could not refresh wallet authentication.`, - message: error.message, - level: LEVELS.error, - }) - } finally { - return resolve(await snapshot()) + return new Promise(async (resolve, reject) => { + spawnCurrentUser() + const opts = {redir} + const user = await snapshot() + const discoveryService = await getDiscoveryService(service) + const refreshService = serviceOfType(user.services, "authn-refresh") + let accountProofData + + if (user.loggedIn) { + if (refreshService) { + try { + const response = await execService({ + service: refreshService, + msg: accountProofData, + opts, + platform, + }) + send(NAME, SET_CURRENT_USER, await buildUser(response)) + } catch (error) { + log({ + title: `${error.name} Could not refresh wallet authentication.`, + message: error.message, + level: LEVELS.error, + }) + } finally { + return resolve(await snapshot()) + } + } else { + return resolve(user) } - } else { - return resolve(user) } - } - try { - accountProofData = await getAccountProofData() - } catch (error) { - log({ - title: `${error.name} On Authentication: Could not resolve account proof data.`, - message: error.message, - level: LEVELS.error, - }) - return reject(error) - } + try { + accountProofData = await getAccountProofData() + } catch (error) { + log({ + title: `${error.name} On Authentication: Could not resolve account proof data.`, + message: error.message, + level: LEVELS.error, + }) + return reject(error) + } - try { - const response = await execService({ - service: discoveryService, - msg: accountProofData, - config: await makeConfig(discoveryService), - opts, - platform, - }) - send(NAME, SET_CURRENT_USER, await buildUser(response)) - } catch (error) { - log({ - title: `${error} On Authentication`, - message: error, - level: LEVELS.error, - }) - } finally { - resolve(await snapshot()) - } - }) -} + try { + const response = await execService({ + service: discoveryService, + msg: accountProofData, + config: await makeConfig(discoveryService), + opts, + platform, + }) + send(NAME, SET_CURRENT_USER, await buildUser(response)) + } catch (error) { + log({ + title: `${error} On Authentication`, + message: error, + level: LEVELS.error, + }) + } finally { + resolve(await snapshot()) + } + }) + } /** * @description - Unauthenticate a user @@ -242,98 +244,102 @@ const normalizePreAuthzResponse = authz => ({ authorization: (authz || {}).authorization || [], }) -const getResolvePreAuthz = ({platform}) => (authz) => { - const resp = normalizePreAuthzResponse(authz) - const axs = [] - - if (resp.proposer != null) axs.push(["PROPOSER", resp.proposer]) - for (let az of resp.payer || []) axs.push(["PAYER", az]) - for (let az of resp.authorization || []) axs.push(["AUTHORIZER", az]) - - var result = axs.map(([role, az]) => ({ - tempId: [az.identity.address, az.identity.keyId].join("|"), - addr: az.identity.address, - keyId: az.identity.keyId, - signingFunction(signable) { - return execService({service: az, msg: signable, platform}) - }, - role: { - proposer: role === "PROPOSER", - payer: role === "PAYER", - authorizer: role === "AUTHORIZER", - }, - })) - return result -} +const getResolvePreAuthz = + ({platform}) => + authz => { + const resp = normalizePreAuthzResponse(authz) + const axs = [] + + if (resp.proposer != null) axs.push(["PROPOSER", resp.proposer]) + for (let az of resp.payer || []) axs.push(["PAYER", az]) + for (let az of resp.authorization || []) axs.push(["AUTHORIZER", az]) + + var result = axs.map(([role, az]) => ({ + tempId: [az.identity.address, az.identity.keyId].join("|"), + addr: az.identity.address, + keyId: az.identity.keyId, + signingFunction(signable) { + return execService({service: az, msg: signable, platform}) + }, + role: { + proposer: role === "PROPOSER", + payer: role === "PAYER", + authorizer: role === "AUTHORIZER", + }, + })) + return result + } /** * @description * Produces the needed authorization details for the current user to submit transactions to Flow * It defines a signing function that connects to a user's wallet provider to produce signatures to submit transactions. - * + * * @param {object} ops - running options * @param {string} ops.platform - platform that runs the function * @param {object} account - Account object * @returns {Promise} - Account object with signing function */ -const getAuthorization = ({platform}) => async (account) => { - spawnCurrentUser() +const getAuthorization = + ({platform}) => + async account => { + spawnCurrentUser() - return { - ...account, - tempId: "CURRENT_USER", - async resolve(account, preSignable) { - const user = await getAuthenticate({platform})({redir: true}) - const authz = serviceOfType(user.services, "authz") - const preAuthz = serviceOfType(user.services, "pre-authz") - - if (preAuthz) - return getResolvePreAuthz({platform})( - await execService({ - service: preAuthz, - msg: preSignable, - platform, - }) - ) - if (authz) { - let windowRef - if (isMobile() && authz.method === "WC/RPC") { - windowRef = window.open("", "_blank") - } - return { - ...account, - tempId: "CURRENT_USER", - resolve: null, - addr: sansPrefix(authz.identity.address), - keyId: authz.identity.keyId, - sequenceNum: null, - signature: null, - async signingFunction(signable) { - return normalizeCompositeSignature( - await execService({ - service: authz, - msg: signable, - opts: { - includeOlderJsonRpcCall: true, - windowRef, - }, - platform, - }) - ) - }, + return { + ...account, + tempId: "CURRENT_USER", + async resolve(account, preSignable) { + const user = await getAuthenticate({platform})({redir: true}) + const authz = serviceOfType(user.services, "authz") + const preAuthz = serviceOfType(user.services, "pre-authz") + + if (preAuthz) + return getResolvePreAuthz({platform})( + await execService({ + service: preAuthz, + msg: preSignable, + platform, + }) + ) + if (authz) { + let windowRef + if (isMobile() && authz.method === "WC/RPC") { + windowRef = window.open("", "_blank") + } + return { + ...account, + tempId: "CURRENT_USER", + resolve: null, + addr: sansPrefix(authz.identity.address), + keyId: authz.identity.keyId, + sequenceNum: null, + signature: null, + async signingFunction(signable) { + return normalizeCompositeSignature( + await execService({ + service: authz, + msg: signable, + opts: { + includeOlderJsonRpcCall: true, + windowRef, + }, + platform, + }) + ) + }, + } } - } - throw new Error( - "No Authz or PreAuthz Service configured for CURRENT_USER" - ) - }, + throw new Error( + "No Authz or PreAuthz Service configured for CURRENT_USER" + ) + }, + } } -} /** * @description * The callback passed to subscribe will be called when the user authenticates and un-authenticates, making it easy to update the UI accordingly. - * + * * @param {Function} callback - Callback function * @returns {Function} - Unsubscribe function */ @@ -372,15 +378,17 @@ async function info() { /** * @description - Resolves the current user as an argument - * + * * @param {object} ops - running options * @param {string} ops.platform - platform that runs the function * @returns {Promise} */ -const getResolveArgument = ({platform}) => async () => { - const {addr} = await getAuthenticate({platform})() - return arg(withPrefix(addr), t.Address) -} +const getResolveArgument = + ({platform}) => + async () => { + const {addr} = await getAuthenticate({platform})() + return arg(withPrefix(addr), t.Address) + } const makeSignable = msg => { invariant(/^[0-9a-f]+$/i.test(msg), "Message must be a hex string") @@ -395,33 +403,34 @@ const makeSignable = msg => { * @param {string} msg - Message to sign * @returns {Promise} - Array of CompositeSignatures */ -const getSignUserMessage = ({platform}) => async (msg) => { - spawnCurrentUser() - const user = await getAuthenticate({platform})({redir: true}) +const getSignUserMessage = + ({platform}) => + async msg => { + spawnCurrentUser() + const user = await getAuthenticate({platform})({redir: true}) - const signingService = serviceOfType(user.services, "user-signature") + const signingService = serviceOfType(user.services, "user-signature") - invariant( - signingService, - "Current user must have authorized a signing service." - ) + invariant( + signingService, + "Current user must have authorized a signing service." + ) - try { - const response = await execService({ - service: signingService, - msg: makeSignable(msg), - platform, - }) - if (Array.isArray(response)) { - return response.map(compSigs => normalizeCompositeSignature(compSigs)) - } else { - return [normalizeCompositeSignature(response)] + try { + const response = await execService({ + service: signingService, + msg: makeSignable(msg), + platform, + }) + if (Array.isArray(response)) { + return response.map(compSigs => normalizeCompositeSignature(compSigs)) + } else { + return [normalizeCompositeSignature(response)] + } + } catch (error) { + return error } - } catch (error) { - return error } -} - const getCurrentUser = ({platform}) => { let currentUser = () => { diff --git a/packages/fcl/src/fcl-react-native.js b/packages/fcl/src/fcl-react-native.ts similarity index 100% rename from packages/fcl/src/fcl-react-native.js rename to packages/fcl/src/fcl-react-native.ts diff --git a/packages/fcl/src/fcl.js b/packages/fcl/src/fcl.ts similarity index 90% rename from packages/fcl/src/fcl.js rename to packages/fcl/src/fcl.ts index 2b3677330..aad1d821a 100644 --- a/packages/fcl/src/fcl.js +++ b/packages/fcl/src/fcl.ts @@ -1,10 +1,11 @@ -export * from './shared-exports'; +export * from "./shared-exports" import {getMutate} from "./exec/mutate" + export const mutate = getMutate({platform: "web"}) import {getCurrentUser} from "./current-user" -const currentUser = getCurrentUser({platform:"web"}) +const currentUser = getCurrentUser({platform: "web"}) export {currentUser} diff --git a/packages/rlp/.babelrc b/packages/rlp/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/rlp/.babelrc +++ b/packages/rlp/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/rlp/.eslintrc.json b/packages/rlp/.eslintrc.json new file mode 100644 index 000000000..815f845bc --- /dev/null +++ b/packages/rlp/.eslintrc.json @@ -0,0 +1,30 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "jsdoc/require-jsdoc": 0, + "jsdoc/tag-lines": 0, + "jsdoc/require-param-description": 0, + "jsdoc/require-param": 0, + "jsdoc/valid-types": 0, + "jsdoc/require-returns-description": 0, + "jsdoc/require-returns": 0, + "@typescript-eslint/no-explicit-any": "off" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/rlp/CHANGELOG.md b/packages/rlp/CHANGELOG.md index 7b291c04e..92f794697 100644 --- a/packages/rlp/CHANGELOG.md +++ b/packages/rlp/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/rlp +## 1.2.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/rlp/package.json b/packages/rlp/package.json index 8ef472694..b9e68c822 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/rlp", - "version": "1.1.0", + "version": "1.2.0", "description": "Port of ethereumjs/rlp", "license": "MPL-2.0", "author": "Dapper Labs ", @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/rlp.js", "module": "dist/rlp.module.js", "unpkg": "dist/rlp.umd.js", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/rlp/src/index.test.js b/packages/rlp/src/index.test.ts similarity index 100% rename from packages/rlp/src/index.test.js rename to packages/rlp/src/index.test.ts diff --git a/packages/rlp/src/index.js b/packages/rlp/src/index.ts similarity index 80% rename from packages/rlp/src/index.js rename to packages/rlp/src/index.ts index 3bd3a4d29..1ed6933f2 100644 --- a/packages/rlp/src/index.js +++ b/packages/rlp/src/index.ts @@ -2,6 +2,15 @@ import {Buffer} from "buffer" export {Buffer} +type EncodeInput = + | Buffer + | string + | number + | Uint8Array + | null + | undefined + | EncodeInput[] + /** * Built on top of rlp library, removing the BN dependency for the flow. * Package : https://github.com/ethereumjs/rlp @@ -10,22 +19,22 @@ export {Buffer} * ethereumjs/rlp is licensed under the * Mozilla Public License 2.0 * Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. - **/ + */ /** * @param input - will be converted to buffer * @returns returns buffer of encoded data - **/ -export function encode(input) { + */ +export function encode(input: EncodeInput): Buffer { if (Array.isArray(input)) { - var output = [] - for (var i = 0; i < input.length; i++) { + const output = [] + for (let i = 0; i < input.length; i++) { output.push(encode(input[i])) } - var buf = Buffer.concat(output) + const buf = Buffer.concat(output) return Buffer.concat([encodeLength(buf.length, 192), buf]) } else { - var inputBuf = toBuffer(input) + const inputBuf = toBuffer(input) return inputBuf.length === 1 && inputBuf[0] < 128 ? inputBuf : Buffer.concat([encodeLength(inputBuf.length, 128), inputBuf]) @@ -37,19 +46,19 @@ export function encode(input) { * @param v The value to parse * @param base The base to parse the integer into */ -function safeParseInt(v, base) { +function safeParseInt(v: string, base: number): number { if (v.slice(0, 2) === "00") { throw new Error("invalid RLP: extra zeros") } return parseInt(v, base) } -function encodeLength(len, offset) { +function encodeLength(len: number, offset: number): Buffer { if (len < 56) { return Buffer.from([len + offset]) } else { - var hexLength = intToHex(len) - var lLength = hexLength.length / 2 - var firstByte = intToHex(offset + 55 + lLength) + const hexLength = intToHex(len) + const lLength = hexLength.length / 2 + const firstByte = intToHex(offset + 55 + lLength) return Buffer.from(firstByte + hexLength, "hex") } } @@ -62,22 +71,22 @@ function encodeLength(len, offset) { * ethereumjs/rlp is licensed under the * Mozilla Public License 2.0 * Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work. - **/ + */ /** * @param input - will be converted to buffer * @param stream Is the input a stream (false by default) * @returns returns buffer of encoded data - **/ -export function decode(input, stream) { + */ +export function decode(input: Buffer | Uint8Array, stream?: boolean): Buffer { if (stream === void 0) { stream = false } if (!input || input.length === 0) { return Buffer.from([]) } - var inputBuffer = toBuffer(input) - var decoded = _decode(inputBuffer) + const inputBuffer = toBuffer(input) + const decoded = _decode(inputBuffer) if (stream) { return decoded } @@ -92,12 +101,15 @@ export function decode(input, stream) { * @param input * @returns The length of the input or an empty Buffer if no input */ -export function getLength(input) { - if (!input || input.length === 0) { - return Buffer.from([]) +export function getLength( + input: Buffer | Uint8Array | null | undefined | string | number +): number { + const inputBuffer = toBuffer(input) + if (inputBuffer.length === 0) { + return 0 } - var inputBuffer = toBuffer(input) - var firstByte = inputBuffer[0] + + const firstByte = inputBuffer[0] if (firstByte <= 0x7f) { return inputBuffer.length } else if (firstByte <= 0xb7) { @@ -109,17 +121,20 @@ export function getLength(input) { return firstByte - 0xbf } else { // a list over 55 bytes long - var llength = firstByte - 0xf6 - var length = safeParseInt(inputBuffer.slice(1, llength).toString("hex"), 16) + const llength = firstByte - 0xf6 + const length = safeParseInt( + inputBuffer.slice(1, llength).toString("hex"), + 16 + ) return llength + length } } /** Decode an input with RLP */ -function _decode(input) { - var length, llength, data, innerRemainder, d - var decoded = [] - var firstByte = input[0] +function _decode(input: Buffer | Uint8Array): any { + let length, llength, data, innerRemainder, d + const decoded = [] + const firstByte = input[0] if (firstByte <= 0x7f) { // a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding. return { @@ -171,7 +186,7 @@ function _decode(input) { // a list over 55 bytes long llength = firstByte - 0xf6 length = safeParseInt(input.slice(1, llength).toString("hex"), 16) - var totalLength = llength + length + const totalLength = llength + length if (totalLength > input.length) { throw new Error("invalid rlp: total length is larger than the data") } @@ -191,36 +206,38 @@ function _decode(input) { } } /** Check if a string is prefixed by 0x */ -function isHexPrefixed(str) { +function isHexPrefixed(str: string) { return str.slice(0, 2) === "0x" } /** Removes 0x from a given String */ -function stripHexPrefix(str) { +function stripHexPrefix(str: string) { if (typeof str !== "string") { return str } return isHexPrefixed(str) ? str.slice(2) : str } /** Transform an integer into its hexadecimal value */ -function intToHex(integer) { +function intToHex(integer: number) { if (integer < 0) { throw new Error("Invalid integer as argument, must be unsigned!") } - var hex = integer.toString(16) + const hex = integer.toString(16) return hex.length % 2 ? "0" + hex : hex } /** Pad a string to be even */ -function padToEven(a) { +function padToEven(a: string) { return a.length % 2 ? "0" + a : a } /** Transform an integer into a Buffer */ -function intToBuffer(integer) { - var hex = intToHex(integer) +function intToBuffer(integer: number) { + const hex = intToHex(integer) return Buffer.from(hex, "hex") } /** Transform anything into a Buffer */ -export function toBuffer(v) { +export function toBuffer( + v: Buffer | string | number | Uint8Array | null | undefined +) { if (!Buffer.isBuffer(v)) { if (typeof v === "string") { if (isHexPrefixed(v)) { diff --git a/packages/rlp/tsconfig.json b/packages/rlp/tsconfig.json new file mode 100644 index 000000000..ac6917898 --- /dev/null +++ b/packages/rlp/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types" + } +} diff --git a/packages/sdk/.babelrc b/packages/sdk/.babelrc index 779f5464f..1e3225d50 100644 --- a/packages/sdk/.babelrc +++ b/packages/sdk/.babelrc @@ -5,6 +5,7 @@ { "useBuiltIns": false } - ] + ], + "@babel/preset-typescript" ] } diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index f8358f112..e6c585258 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,41 @@ # @onflow/sdk +## 1.3.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477), [`92b966d3`](https://github.com/onflow/fcl-js/commit/92b966d39936ba0a90629ee320e62e4fed5d2296)]: + - @onflow/transport-http@1.8.0 + - @onflow/util-invariant@1.2.0 + - @onflow/util-template@1.2.0 + - @onflow/util-address@1.2.0 + - @onflow/util-logger@1.3.0 + - @onflow/util-actor@1.3.0 + - @onflow/config@1.2.0 + - @onflow/rlp@1.2.0 + +## 1.3.0-alpha.0 + +### Minor Changes + +- TS build + +### Patch Changes + +- Updated dependencies []: + - @onflow/transport-http@1.8.0-alpha.0 + - @onflow/util-invariant@1.2.0-alpha.0 + - @onflow/util-template@1.2.0-alpha.0 + - @onflow/util-address@1.2.0-alpha.0 + - @onflow/util-logger@1.3.0-alpha.0 + - @onflow/util-actor@1.3.0-alpha.0 + - @onflow/config@1.2.0-alpha.0 + - @onflow/rlp@1.2.0-alpha.0 + ## 1.2.2 ### Patch Changes diff --git a/packages/sdk/package.json b/packages/sdk/package.json index c0b7c8913..91477a291 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/sdk", - "version": "1.2.2", + "version": "1.3.0", "description": "Flow SDK", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -18,14 +18,14 @@ } }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/typedefs": "^1.1.1", + "@onflow/fcl-bundle": "^1.4.0", + "@onflow/typedefs": "^1.2.0", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", "typescript": "^4.9.5" }, - "source": "src/sdk.js", + "source": "src/sdk.ts", "main": "dist/sdk.js", "module": "dist/sdk.module.js", "unpkg": "dist/sdk.umd.js", @@ -35,21 +35,20 @@ "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", - "build:types": "tsc", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/config": "^1.1.1", - "@onflow/rlp": "^1.1.0", - "@onflow/transport-http": "^1.7.1", - "@onflow/util-actor": "^1.2.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1", - "@onflow/util-template": "^1.1.0", + "@onflow/config": "^1.2.0", + "@onflow/rlp": "^1.2.0", + "@onflow/transport-http": "^1.8.0", + "@onflow/util-actor": "^1.3.0", + "@onflow/util-address": "^1.2.0", + "@onflow/util-invariant": "^1.2.0", + "@onflow/util-logger": "^1.3.0", + "@onflow/util-template": "^1.2.0", "deepmerge": "^4.2.2", "sha3": "^2.1.4" } diff --git a/packages/sdk/src/resolve/resolve-accounts.test.js b/packages/sdk/src/resolve/resolve-accounts.test.js index c50bd6378..4fddbb556 100644 --- a/packages/sdk/src/resolve/resolve-accounts.test.js +++ b/packages/sdk/src/resolve/resolve-accounts.test.js @@ -7,7 +7,7 @@ import { payer, limit, authorizations, -} from "../sdk.js" +} from "../sdk" import {buildPreSignable} from "./resolve-accounts" test("Voucher in PreSignable", async () => { diff --git a/packages/sdk/src/resolve/resolve-arguments.test.js b/packages/sdk/src/resolve/resolve-arguments.test.js index 79ec830c4..ebf30cea7 100644 --- a/packages/sdk/src/resolve/resolve-arguments.test.js +++ b/packages/sdk/src/resolve/resolve-arguments.test.js @@ -1,4 +1,4 @@ -import {resolveArguments} from "../sdk.js" +import {resolveArguments} from "../sdk" describe("resolveArguments", () => { const argID = "28948a11n4" diff --git a/packages/sdk/src/resolve/resolve-signatures.test.js b/packages/sdk/src/resolve/resolve-signatures.test.js index 5bbc888f7..30465ad7e 100644 --- a/packages/sdk/src/resolve/resolve-signatures.test.js +++ b/packages/sdk/src/resolve/resolve-signatures.test.js @@ -8,7 +8,7 @@ import { payer, limit, authorizations, -} from "../sdk.js" +} from "../sdk" const signingFunction = jest.fn(() => ({ addr: "foo", diff --git a/packages/sdk/src/sdk.test.js b/packages/sdk/src/sdk.test.js index a86d9ddf8..9ee3543eb 100644 --- a/packages/sdk/src/sdk.test.js +++ b/packages/sdk/src/sdk.test.js @@ -10,7 +10,7 @@ import { payer, authorization, VERSION, -} from "./sdk.js" +} from "./sdk" test("fcl.VERSION needs to match version in package.json", () => { expect(VERSION).toBe("TESTVERSION") diff --git a/packages/sdk/src/sdk.js b/packages/sdk/src/sdk.ts similarity index 97% rename from packages/sdk/src/sdk.js rename to packages/sdk/src/sdk.ts index 6e0f2adc9..9a4decc99 100644 --- a/packages/sdk/src/sdk.js +++ b/packages/sdk/src/sdk.ts @@ -83,7 +83,7 @@ export {resolveVoucherIntercept} from "./resolve/resolve-voucher-intercept.js" export {config} from "@onflow/config" // Deprecated -export const params = params => +export const params = (params: never) => logger.log.deprecate({ pkg: "FCL/SDK", message: `The params builder has been removed from the Flow JS-SDK/FCL.`, @@ -91,7 +91,7 @@ export const params = params => "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", level: logger.LEVELS.error, }) -export const param = params => +export const param = (params: never) => logger.log.deprecate({ pkg: "FCL/SDK", message: `The param builder has been removed from the Flow JS-SDK/FCL.`, @@ -103,4 +103,4 @@ export const param = params => import * as TestUtils from "./test-utils" export {TestUtils} -export {VERSION} from "./VERSION" \ No newline at end of file +export {VERSION} from "./VERSION" diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index ef17eba8e..ac6917898 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -1,24 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files - "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, + "outDir": "types" } -} \ No newline at end of file +} diff --git a/packages/transport-grpc/CHANGELOG.md b/packages/transport-grpc/CHANGELOG.md index 24cb60afb..3e08354ce 100644 --- a/packages/transport-grpc/CHANGELOG.md +++ b/packages/transport-grpc/CHANGELOG.md @@ -1,5 +1,33 @@ # @onflow/transport-grpc +## 1.3.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477)]: + - @onflow/util-invariant@1.2.0 + - @onflow/util-template@1.2.0 + - @onflow/util-address@1.2.0 + - @onflow/rlp@1.2.0 + +## 1.3.0-alpha.0 + +### Minor Changes + +- TS build + +### Patch Changes + +- Updated dependencies []: + - @onflow/util-invariant@1.2.0-alpha.0 + - @onflow/util-template@1.2.0-alpha.0 + - @onflow/util-address@1.2.0-alpha.0 + - @onflow/rlp@1.2.0-alpha.0 + ## 1.2.1 ### Patch Changes diff --git a/packages/transport-grpc/package.json b/packages/transport-grpc/package.json index 8f02d2008..c1e708822 100644 --- a/packages/transport-grpc/package.json +++ b/packages/transport-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/transport-grpc", - "version": "1.2.1", + "version": "1.3.0", "description": "Flow SDK GRPC Transport Module", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,8 +13,8 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/sdk": "^1.2.1", + "@onflow/fcl-bundle": "^1.4.0", + "@onflow/sdk": "^1.3.0", "jest": "^29.5.0" }, "source": "src/sdk-send-grpc.js", @@ -34,9 +34,9 @@ "@improbable-eng/grpc-web": "^0.14.0", "@improbable-eng/grpc-web-node-http-transport": "^0.14.0", "@onflow/protobuf": "^1.2.1", - "@onflow/rlp": "^1.1.0", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-template": "^1.1.0" + "@onflow/rlp": "^1.2.0", + "@onflow/util-address": "^1.2.0", + "@onflow/util-invariant": "^1.2.0", + "@onflow/util-template": "^1.2.0" } } diff --git a/packages/transport-grpc/tsconfig.json b/packages/transport-grpc/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/transport-grpc/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/transport-http/CHANGELOG.md b/packages/transport-http/CHANGELOG.md index bcd070d1b..63c059065 100644 --- a/packages/transport-http/CHANGELOG.md +++ b/packages/transport-http/CHANGELOG.md @@ -1,5 +1,33 @@ # @onflow/transport-http +## 1.8.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477)]: + - @onflow/util-invariant@1.2.0 + - @onflow/util-template@1.2.0 + - @onflow/util-address@1.2.0 + - @onflow/util-logger@1.3.0 + +## 1.8.0-alpha.0 + +### Minor Changes + +- TS build + +### Patch Changes + +- Updated dependencies []: + - @onflow/util-invariant@1.2.0-alpha.0 + - @onflow/util-template@1.2.0-alpha.0 + - @onflow/util-address@1.2.0-alpha.0 + - @onflow/util-logger@1.3.0-alpha.0 + ## 1.7.1 ### Patch Changes diff --git a/packages/transport-http/package.json b/packages/transport-http/package.json index cd27d29fd..d8eb9a1ac 100644 --- a/packages/transport-http/package.json +++ b/packages/transport-http/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/transport-http", - "version": "1.7.1", + "version": "1.8.0", "description": "Flow SDK HTTP Transport Module", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,10 +13,10 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", - "@onflow/rlp": "^1.1.0", - "@onflow/sdk": "^1.2.2", - "@onflow/types": "^1.1.0", + "@onflow/fcl-bundle": "^1.4.0", + "@onflow/rlp": "^1.2.0", + "@onflow/sdk": "^1.3.0", + "@onflow/types": "^1.2.0", "jest": "^29.5.0" }, "source": "src/sdk-send-http.js", @@ -33,10 +33,10 @@ }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/util-address": "^1.1.0", - "@onflow/util-invariant": "^1.1.0", - "@onflow/util-logger": "^1.2.1", - "@onflow/util-template": "^1.1.0", + "@onflow/util-address": "^1.2.0", + "@onflow/util-invariant": "^1.2.0", + "@onflow/util-logger": "^1.3.0", + "@onflow/util-template": "^1.2.0", "abort-controller": "^3.0.0", "cross-fetch": "^3.1.6" } diff --git a/packages/transport-http/tsconfig.json b/packages/transport-http/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/transport-http/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/typedefs/CHANGELOG.md b/packages/typedefs/CHANGELOG.md index 2180a078a..a0a054d3b 100644 --- a/packages/typedefs/CHANGELOG.md +++ b/packages/typedefs/CHANGELOG.md @@ -1,5 +1,17 @@ # @onflow/typedefs +## 1.2.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.1.1 ### Patch Changes diff --git a/packages/typedefs/package.json b/packages/typedefs/package.json index fbe513cf7..3c09ed194 100644 --- a/packages/typedefs/package.json +++ b/packages/typedefs/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/typedefs", - "version": "1.1.1", + "version": "1.2.0", "description": "Flow JS Type Defs", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,7 +13,7 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@onflow/fcl-bundle": "^1.4.0", "@types/node": "^18.13.0", "eslint": "^8.33.0", "eslint-plugin-jsdoc": "^39.7.5", @@ -21,16 +21,15 @@ "jest-esm-transformer": "1.0.0", "typescript": "^4.9.5" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/typedefs.js", "module": "dist/typedefs.module.js", "unpkg": "dist/typedefs.umd.js", - "types": "types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", - "build:types": "tsc", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." diff --git a/packages/typedefs/src/index.js b/packages/typedefs/src/index.js deleted file mode 100644 index f08314863..000000000 --- a/packages/typedefs/src/index.js +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @typedef {object} Account - * @property {string} address - The address of the account - * @property {number} balance - The FLOW balance of the account in 10^8 - * @property {number} code - The code of any Cadence contracts stored in the account - * @property {object} contracts - An object with keys as the contract name deployed and the value as the the cadence string - * @property {object} keys - Any contracts deployed to this account - */ - -/** - * @typedef {object} Block - * @property {string} id - The id of the block - * @property {string} parentId - The id of the parent block - * @property {number} height - The height of the block - * @property {object} timestamp - Time related fields - * @property {CollectionGuarantee} collectionGuarantees - Contains the ids of collections included in the block - * @property {object} blockSeals - The details of which nodes executed and sealed the blocks - * @property {Array} signatures - The cryptographic signature of the block - */ - -/** - * @typedef {object} CollectionGuarantee - * @property {string} collectionId - The id of the block - * @property {Array} signatures - All signatures - */ - -/** - * @typedef {object} CompositeSignature - * @property {string} f_type - A type identifier used internally by FCL - * @property {string} f_vsn - FCL protocol version - * @property {string} addr - Flow Address (sans prefix) - * @property {number} keyId - Key ID - * @property {string} signature - Signature as a hex string - */ - -/** - * @typedef {object} CurrentUser - * @property {string} [addr] - The public address of the current user - * @property {string} [cid] - A wallet specified content identifier for user metadata - * @property {number} [expiresAt] - A wallet specified time-frame for a valid session - * @property {string} f_type - A type identifier used internally by FCL - * @property {string} f_vsn - FCL protocol version - * @property {boolean} [loggedIn] - Whether or not the current user is logged in - * @property {Array} services - A list of trusted services that express ways of interacting with the current user's identity - */ - -/** - * @typedef {object} Event - * @property {string} blockId - ID of the block that contains the event. - * @property {number} blockHeight - Height of the block that contains the event. - * @property {string} blockTimestamp - The timestamp of when the block was sealed in a DateString format. eg. '2021-06-25T13:42:04.227Z' - * @property {string} type - A string containing the event name. - * @property {string} transactionId - Can be used to query transaction information, eg. via a Flow block explorer. - * @property {number} transactionIndex - Used to prevent replay attacks. - * @property {number} eventIndex - Used to prevent replay attacks. - * @property {any} data - The data emitted from the event. - */ - -/** - * @typedef {object} Key - * @property {number} sequenceNumber - Sequence number of key used by the proposer of this transaction - * @property {number} keyId - The ID of the key in the account used by the proposer of this transaction - * @property {string} address - The address of the proposer of this transaction - */ - -/** - * @typedef {object} Service - * @property {string} f_type - A type identifier used internally by FCL - * @property {string} f_vsn - FCL protocol version - * @property {string} type - Service type - * @property {string} method - Service method - * @property {string} [uid] - Service uid - * @property {string} endpoint - Service endpoint - * @property {Provider} provider - Service provider object - */ - -/** - * @typedef {object} Signature - * @property {string} sequenceNumber - Sequence number of the key used to perform this signature. - * @property {number} keyId - ID of the key in the account used to perform this signature. - * @property {string} signature - The signature represented as a hex string. - */ - -/** - * @typedef {object} Transaction - * @property {string} script - The Cadence code used to execute this transaction. - * @property {Array} args - The JSON-CDC encoded arguments passed in to the transaction. - * @property {string} referenceBlockId - The reference block id for this transaction. - * @property {number} gasLimit - The gas limit for the transaction. - * @property {Key} proposalKey - The key used by the proposer of this transaction. - * @property {string} sequenceNumber - Sequence number of the key used by the proposer of this transaction. - * @property {number} keyId - The ID of the key in the account used by the proposer of this transaction. - * @property {string} address - The address of the proposer of this transaction. - * @property {string} payer - Address of the payer of the transaction. - * @property {string} proposer - Address of the proposer of this transaction. - * @property {Array} authorizers - Array of addresses of authorizers of this transaction. - * @property {Array} payloadSignatures - The payload signatures for the transaction. - * @property {Array} envelopeSignatures - The envelope signatures for the transaction. - */ - -/** - * @typedef {object} TransactionStatus - * @property {string} blockId - The ID of the Block the transaction is included in. - * @property {number} status - The status code of the transaction. - * @property {string} statusString - The status as as descriptive text (e.g. "FINALIZED"). - * @property {string} errorMessage - The error message of the transaction. - * @property {Array} events - The events for this result. - */ - -/** - * @typedef {object} Provider - * @property {string} name - Provider name. - * @todo fill the rest - */ - -// Needed for bundler to export this file -exports.unused = {} diff --git a/packages/typedefs/src/index.ts b/packages/typedefs/src/index.ts new file mode 100644 index 000000000..5971369c2 --- /dev/null +++ b/packages/typedefs/src/index.ts @@ -0,0 +1,290 @@ +export type Account = { + /** + * - The address of the account + */ + address: string + /** + * - The FLOW balance of the account in 10^8 + */ + balance: number + /** + * - The code of any Cadence contracts stored in the account + */ + code: number + /** + * - An object with keys as the contract name deployed and the value as the the cadence string + */ + contracts: object + /** + * - Any contracts deployed to this account + */ + keys: object +} +export type Block = { + /** + * - The id of the block + */ + id: string + /** + * - The id of the parent block + */ + parentId: string + /** + * - The height of the block + */ + height: number + /** + * - Time related fields + */ + timestamp: object + /** + * - Contains the ids of collections included in the block + */ + collectionGuarantees: CollectionGuarantee + /** + * - The details of which nodes executed and sealed the blocks + */ + blockSeals: object + /** + * - The cryptographic signature of the block + */ + signatures: Array +} +export type CollectionGuarantee = { + /** + * - The id of the block + */ + collectionId: string + /** + * - All signatures + */ + signatures: Array +} +export type CompositeSignature = { + /** + * - A type identifier used internally by FCL + */ + f_type: string + /** + * - FCL protocol version + */ + f_vsn: string + /** + * - Flow Address (sans prefix) + */ + addr: string + /** + * - Key ID + */ + keyId: number + /** + * - Signature as a hex string + */ + signature: string +} +export type CurrentUser = { + /** + * - The public address of the current user + */ + addr?: string + /** + * - A wallet specified content identifier for user metadata + */ + cid?: string + /** + * - A wallet specified time-frame for a valid session + */ + expiresAt?: number + /** + * - A type identifier used internally by FCL + */ + f_type: string + /** + * - FCL protocol version + */ + f_vsn: string + /** + * - Whether or not the current user is logged in + */ + loggedIn?: boolean + /** + * - A list of trusted services that express ways of interacting with the current user's identity + */ + services: Array +} +export type Event = { + /** + * - ID of the block that contains the event. + */ + blockId: string + /** + * - Height of the block that contains the event. + */ + blockHeight: number + /** + * - The timestamp of when the block was sealed in a DateString format. eg. '2021-06-25T13:42:04.227Z' + */ + blockTimestamp: string + /** + * - A string containing the event name. + */ + type: string + /** + * - Can be used to query transaction information, eg. via a Flow block explorer. + */ + transactionId: string + /** + * - Used to prevent replay attacks. + */ + transactionIndex: number + /** + * - Used to prevent replay attacks. + */ + eventIndex: number + /** + * - The data emitted from the event. + */ + data: any +} +export type Key = { + /** + * - Sequence number of key used by the proposer of this transaction + */ + sequenceNumber: number + /** + * - The ID of the key in the account used by the proposer of this transaction + */ + keyId: number + /** + * - The address of the proposer of this transaction + */ + address: string +} +export type Service = { + /** + * - A type identifier used internally by FCL + */ + f_type: string + /** + * - FCL protocol version + */ + f_vsn: string + /** + * - Service type + */ + type: string + /** + * - Service method + */ + method: string + /** + * - Service uid + */ + uid?: string + /** + * - Service endpoint + */ + endpoint: string + /** + * - Service provider object + */ + provider: Provider + + params: Record +} +export type Signature = { + /** + * - Sequence number of the key used to perform this signature. + */ + sequenceNumber: string + /** + * - ID of the key in the account used to perform this signature. + */ + keyId: number + /** + * - The signature represented as a hex string. + */ + signature: string +} +export type Transaction = { + /** + * - The Cadence code used to execute this transaction. + */ + script: string + /** + * - The JSON-CDC encoded arguments passed in to the transaction. + */ + args: Array + /** + * - The reference block id for this transaction. + */ + referenceBlockId: string + /** + * - The gas limit for the transaction. + */ + gasLimit: number + /** + * - The key used by the proposer of this transaction. + */ + proposalKey: Key + /** + * - Sequence number of the key used by the proposer of this transaction. + */ + sequenceNumber: string + /** + * - The ID of the key in the account used by the proposer of this transaction. + */ + keyId: number + /** + * - The address of the proposer of this transaction. + */ + address: string + /** + * - Address of the payer of the transaction. + */ + payer: string + /** + * - Address of the proposer of this transaction. + */ + proposer: string + /** + * - Array of addresses of authorizers of this transaction. + */ + authorizers: Array + /** + * - The payload signatures for the transaction. + */ + payloadSignatures: Array + /** + * - The envelope signatures for the transaction. + */ + envelopeSignatures: Array +} +export type TransactionStatus = { + /** + * - The ID of the Block the transaction is included in. + */ + blockId: string + /** + * - The status code of the transaction. + */ + status: number + /** + * - The status as as descriptive text (e.g. "FINALIZED"). + */ + statusString: string + /** + * - The error message of the transaction. + */ + errorMessage: string + /** + * - The events for this result. + */ + events: Array +} +export type Provider = { + /** + * - Provider name. + */ + name: string +} diff --git a/packages/typedefs/tsconfig.json b/packages/typedefs/tsconfig.json index 6bfcb0e73..88be905eb 100644 --- a/packages/typedefs/tsconfig.json +++ b/packages/typedefs/tsconfig.json @@ -1,25 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - "types" : ["node"], - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, } } \ No newline at end of file diff --git a/packages/types/.babelrc b/packages/types/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/types/.babelrc +++ b/packages/types/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/types/.eslintrc.json b/packages/types/.eslintrc.json new file mode 100644 index 000000000..712568225 --- /dev/null +++ b/packages/types/.eslintrc.json @@ -0,0 +1,31 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"], + "overrides": [ + { + "files": ["**/*.test.ts"], + "env": { + "jest": true + }, + "rules": { + "jsdoc/require-jsdoc": 0 + } + } + ] +} diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index d346f1c99..363a8d205 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -1,5 +1,24 @@ # @onflow/types +## 1.2.0 + +### Minor Changes + +- [#1760](https://github.com/onflow/fcl-js/pull/1760) [`0e4a4b1a`](https://github.com/onflow/fcl-js/commit/0e4a4b1aa4d9d18b9f8c2fa1e9db1b8e6ab9b15a) Thanks [@jribbink](https://github.com/jribbink)! - Convert @onflow/types to TypeScript + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +### Patch Changes + +- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477)]: + - @onflow/util-logger@1.3.0 + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/types/package.json b/packages/types/package.json index 25df43c88..c15f88071 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/types", - "version": "1.1.0", + "version": "1.2.0", "description": "Utilities to transform javascript values into Cadence understandable values", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,21 +13,30 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/types.js", + "source": "src/types.ts", "main": "dist/types.js", "module": "dist/types.module.js", "unpkg": "dist/types.umd.js", + "types": "dist/types.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", - "build": "fcl-bundle", + "build": " npm run lint && fcl-bundle", "test:watch": "jest --watch", - "start": "fcl-bundle --watch" + "start": "fcl-bundle --watch", + "lint": "eslint src" }, "dependencies": { - "@babel/runtime": "^7.18.6" + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0" } } diff --git a/packages/types/src/types.test.js b/packages/types/src/types.test.js deleted file mode 100644 index 36a57df3b..000000000 --- a/packages/types/src/types.test.js +++ /dev/null @@ -1,249 +0,0 @@ -import * as t from "./types.js" -;[ - [t.Identity, 0, 0, 0], - [t.Identity, "a", "a", "a"], - [t.Identity, null, null, null], - [t.Int, "1", {type: "Int", value: "1"}, "1"], - [t.UInt, "1", {type: "UInt", value: "1"}, "1"], - [t.Int8, "8", {type: "Int8", value: "8"}, "8"], - [t.UInt8, "8", {type: "UInt8", value: "8"}, "8"], - [t.Int16, "16", {type: "Int16", value: "16"}, "16"], - [t.UInt16, "16", {type: "UInt16", value: "16"}, "16"], - [t.Int32, "32", {type: "Int32", value: "32"}, "32"], - [t.UInt32, "32", {type: "UInt32", value: "32"}, "32"], - [t.Int64, "64", {type: "Int64", value: "64"}, "64"], - [t.UInt64, "64", {type: "UInt64", value: "64"}, "64"], - [t.Int128, "128", {type: "Int128", value: "128"}, "128"], - [t.UInt128, "128", {type: "UInt128", value: "128"}, "128"], - [t.Int256, "256", {type: "Int256", value: "256"}, "256"], - [t.UInt256, "256", {type: "UInt256", value: "256"}, "256"], - [t.Word8, "8", {type: "Word8", value: "8"}, "8"], - [t.Word16, "16", {type: "Word16", value: "16"}, "16"], - [t.Word32, "32", {type: "Word32", value: "32"}, "32"], - [t.Word64, "64", {type: "Word64", value: "64"}, "64"], - [t.UFix64, "64", {type: "UFix64", value: "64"}, "64", true], - [t.Fix64, "64", {type: "Fix64", value: "64"}, "64", true], - [ - t.UFix64, - "64.000000001", - {type: "UFix64", value: "64.000000001"}, - "64.000000001", - true, - ], - [ - t.Fix64, - "64.000000001", - {type: "Fix64", value: "64.000000001"}, - "64.000000001", - true, - ], - [t.UFix64, "64.0", {type: "UFix64", value: "64.00000000"}, "64.0", false], - [t.Fix64, "64.0", {type: "Fix64", value: "64.00000000"}, "64.0", false], - [ - t.String, - "Go with the Flow", - {type: "String", value: "Go with the Flow"}, - "Go with the Flow", - ], - [t.Character, "c", {type: "Character", value: "c"}, "c"], - [t.Bool, true, {type: "Bool", value: true}, true], - [t.Address, "0x1", {type: "Address", value: "0x1"}, "0x1"], - [t.Void, null, {type: "Void"}, null], - [t.Optional(t.String), null, {type: "Optional", value: null}, null], - [ - t.Optional(t.String), - "test", - {type: "Optional", value: {type: "String", value: "test"}}, - "test", - ], - [ - t.Reference, - {address: "0x01", type: "0x01.CryptoKitty"}, - {type: "Reference", value: {address: "0x01", type: "0x01.CryptoKitty"}}, - {address: "0x01", type: "0x01.CryptoKitty"}, - ], - [ - t.Array(t.String), - ["test"], - {type: "Array", value: [{type: "String", value: "test"}]}, - ["test"], - ], - [ - t.Array([t.String, t.String]), - ["test1", "test2"], - { - type: "Array", - value: [ - {type: "String", value: "test1"}, - {type: "String", value: "test2"}, - ], - }, - ["test1", "test2"], - ], - [ - t.Dictionary([ - {key: t.Int, value: t.String}, - {key: t.Int, value: t.String}, - ]), - [ - {key: "1", value: "one"}, - {key: "2", value: "two"}, - ], - { - type: "Dictionary", - value: [ - {key: {type: "Int", value: "1"}, value: {type: "String", value: "one"}}, - {key: {type: "Int", value: "2"}, value: {type: "String", value: "two"}}, - ], - }, - [ - {key: "1", value: "one"}, - {key: "2", value: "two"}, - ], - ], - [ - t.Dictionary({key: t.Int, value: t.String}), - {key: "1", value: "one"}, - { - type: "Dictionary", - value: [ - {key: {type: "Int", value: "1"}, value: {type: "String", value: "one"}}, - ], - }, - {key: "1", value: "one"}, - ], - [ - t.Struct("0x01.Jeffysaur", [{value: t.String}]), - { - fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}], - }, - { - type: "Struct", - value: { - id: "0x01.Jeffysaur", - fields: [ - { - name: "Jeffysaur_Name", - value: {type: "String", value: "Mr Jeff The Dinosaur"}, - }, - ], - }, - }, - { - fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}], - }, - ], - [ - t.Enum("0x01.SuperEnum", [{value: t.String}]), - { - fields: [{name: "SuperKey1", value: "SuperValue1"}], - }, - { - type: "Enum", - value: { - id: "0x01.SuperEnum", - fields: [ - { - name: "SuperKey1", - value: {type: "String", value: "SuperValue1"}, - }, - ], - }, - }, - { - fields: [{name: "SuperKey1", value: "SuperValue1"}], - }, - ], - [ - t.Event("0x01.JeffWroteSomeJS", [{value: t.String}]), - { - fields: [{name: "wasTheCodeClean?", value: "absolutely"}], - }, - { - type: "Event", - value: { - id: "0x01.JeffWroteSomeJS", - fields: [ - { - name: "wasTheCodeClean?", - value: {type: "String", value: "absolutely"}, - }, - ], - }, - }, - { - fields: [{name: "wasTheCodeClean?", value: "absolutely"}], - }, - ], - [ - t.Resource("0x01.Jeffysaur", [{value: t.String}]), - { - fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}], - }, - { - type: "Resource", - value: { - id: "0x01.Jeffysaur", - fields: [ - { - name: "Jeffysaur_Name", - value: {type: "String", value: "Mr Jeff The Dinosaur"}, - }, - ], - }, - }, - { - fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}], - }, - ], - [ - t.Path, - { - domain: "public", - identifier: "flowTokenVault", - }, - { - type: "Path", - value: { - domain: "public", - identifier: "flowTokenVault", - }, - }, - { - domain: "public", - identifier: "flowTokenVault", - }, - ], - [ - t.Path, - { - domain: "notValidDomain", - identifier: "flowTokenVault", - }, - { - type: "Path", - value: { - domain: "notValidDomain", - identifier: "flowTokenVault", - }, - }, - { - domain: "notValidDomain", - identifier: "flowTokenVault", - }, - true, - ], -].forEach(([cast, input, asArgument, asInjection, shouldError = false]) => { - describe(cast.label, () => { - test(`t.${cast.label}.asArgument(${input})`, () => { - if (shouldError) { - expect(() => cast.asArgument(input)).toThrow() - } else { - expect(cast.asArgument(input)).toStrictEqual(asArgument) - } - }) - test(`t.${cast.label}.asInjection(${input})`, () => { - expect(cast.asInjection(input)).toStrictEqual(asInjection) - }) - }) -}) diff --git a/packages/types/src/types.test.ts b/packages/types/src/types.test.ts new file mode 100644 index 000000000..efabee647 --- /dev/null +++ b/packages/types/src/types.test.ts @@ -0,0 +1,245 @@ +import * as t from "./types" + +registerTest([t.Int, "1", {type: "Int", value: "1"}, "1"]) +registerTest([t.UInt, "1", {type: "UInt", value: "1"}, "1"]) +registerTest([t.Int8, "8", {type: "Int8", value: "8"}, "8"]) +registerTest([t.UInt8, "8", {type: "UInt8", value: "8"}, "8"]) +registerTest([t.Int16, "16", {type: "Int16", value: "16"}, "16"]) +registerTest([t.UInt16, "16", {type: "UInt16", value: "16"}, "16"]) +registerTest([t.Int32, "32", {type: "Int32", value: "32"}, "32"]) +registerTest([t.UInt32, "32", {type: "UInt32", value: "32"}, "32"]) +registerTest([t.Int64, "64", {type: "Int64", value: "64"}, "64"]) +registerTest([t.UInt64, "64", {type: "UInt64", value: "64"}, "64"]) +registerTest([t.Int128, "128", {type: "Int128", value: "128"}, "128"]) +registerTest([t.UInt128, "128", {type: "UInt128", value: "128"}, "128"]) +registerTest([t.Int256, "256", {type: "Int256", value: "256"}, "256"]) +registerTest([t.UInt256, "256", {type: "UInt256", value: "256"}, "256"]) +registerTest([t.Word8, "8", {type: "Word8", value: "8"}, "8"]) +registerTest([t.Word16, "16", {type: "Word16", value: "16"}, "16"]) +registerTest([t.Word32, "32", {type: "Word32", value: "32"}, "32"]) +registerTest([t.Word64, "64", {type: "Word64", value: "64"}, "64"]) +registerTest([t.UFix64, "64", {type: "UFix64", value: "64"}, "64", true]) +registerTest([t.Fix64, "64", {type: "Fix64", value: "64"}, "64", true]) +registerTest([ + t.UFix64, + "64.000000001", + {type: "UFix64", value: "64.000000001"}, + "64.000000001", + true, +]) +registerTest([ + t.Fix64, + "64.000000001", + {type: "Fix64", value: "64.000000001"}, + "64.000000001", + true, +]) +registerTest([ + t.UFix64, + "64.0", + {type: "UFix64", value: "64.00000000"}, + "64.0", + false, +]) +registerTest([ + t.Fix64, + "64.0", + {type: "Fix64", value: "64.00000000"}, + "64.0", + false, +]) +registerTest([ + t.String, + "Go with the Flow", + {type: "String", value: "Go with the Flow"}, + "Go with the Flow", +]) +registerTest([t.Character, "c", {type: "Character", value: "c"}, "c"]) +registerTest([t.Bool, true, {type: "Bool", value: true}, true]) +registerTest([t.Address, "0x1", {type: "Address", value: "0x1"}, "0x1"]) +registerTest([t.Void, null, {type: "Void", value: null}, null]) +registerTest([ + t.Optional(t.String), + null, + {type: "Optional", value: null}, + null, +]) +registerTest([ + t.Optional(t.String), + "test", + {type: "Optional", value: {type: "String", value: "test"}}, + "test", +]) +registerTest([ + t.Reference, + {address: "0x01", type: "0x01.CryptoKitty"}, + {type: "Reference", value: {address: "0x01", type: "0x01.CryptoKitty"}}, + {address: "0x01", type: "0x01.CryptoKitty"}, +]) +registerTest([ + t.Array(t.String), + ["test"], + {type: "Array", value: [{type: "String", value: "test"}]}, + ["test"], +]) +registerTest([ + t.Array([t.String, t.String]), + ["test1", "test2"], + { + type: "Array", + value: [ + {type: "String", value: "test1"}, + {type: "String", value: "test2"}, + ], + }, + ["test1", "test2"], +]) +registerTest([ + t.Dictionary([ + {key: t.Int, value: t.String}, + {key: t.Int, value: t.String}, + ]), + [ + {key: "1", value: "one"}, + {key: "2", value: "two"}, + ], + { + type: "Dictionary", + value: [ + {key: {type: "Int", value: "1"}, value: {type: "String", value: "one"}}, + {key: {type: "Int", value: "2"}, value: {type: "String", value: "two"}}, + ], + }, + [ + {key: "1", value: "one"}, + {key: "2", value: "two"}, + ], +]) +registerTest([ + t.Dictionary({key: t.Int, value: t.String}), + {key: "1", value: "one"}, + { + type: "Dictionary", + value: [ + {key: {type: "Int", value: "1"}, value: {type: "String", value: "one"}}, + ], + }, + {key: "1", value: "one"}, +]) +registerTest([ + t.Struct("0x01.Jeffysaur", [{value: t.String}]), + {fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}]}, + { + type: "Struct", + value: { + id: "0x01.Jeffysaur", + fields: [ + { + name: "Jeffysaur_Name", + value: {type: "String", value: "Mr Jeff The Dinosaur"}, + }, + ], + }, + }, + {fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}]}, +]) +registerTest([ + t.Enum("0x01.SuperEnum", [{value: t.String}]), + {fields: [{name: "SuperKey1", value: "SuperValue1"}]}, + { + type: "Enum", + value: { + id: "0x01.SuperEnum", + fields: [ + {name: "SuperKey1", value: {type: "String", value: "SuperValue1"}}, + ], + }, + }, + {fields: [{name: "SuperKey1", value: "SuperValue1"}]}, +]) +registerTest([ + t.Event("0x01.JeffWroteSomeJS", [{value: t.String}]), + {fields: [{name: "wasTheCodeClean?", value: "absolutely"}]}, + { + type: "Event", + value: { + id: "0x01.JeffWroteSomeJS", + fields: [ + { + name: "wasTheCodeClean?", + value: {type: "String", value: "absolutely"}, + }, + ], + }, + }, + {fields: [{name: "wasTheCodeClean?", value: "absolutely"}]}, +]) +registerTest([ + t.Resource("0x01.Jeffysaur", [{value: t.String}]), + {fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}]}, + { + type: "Resource", + value: { + id: "0x01.Jeffysaur", + fields: [ + { + name: "Jeffysaur_Name", + value: {type: "String", value: "Mr Jeff The Dinosaur"}, + }, + ], + }, + }, + {fields: [{name: "Jeffysaur_Name", value: "Mr Jeff The Dinosaur"}]}, +]) +registerTest([ + t.Path, + { + domain: "public" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, + {type: "Path", value: {domain: "public", identifier: "flowTokenVault"}}, + { + domain: "public" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, +]) +registerTest([ + t.Path, + { + domain: "notValidDomain" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, + { + type: "Path", + value: { + domain: "notValidDomain" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, + }, + { + domain: "notValidDomain" as "storage" | "private" | "public", + identifier: "flowTokenVault", + }, + true, +]) + +function registerTest([ + cast, + input, + asArgument, + asInjection, + shouldError = false, +]: readonly [t.TypeDescriptor, X, t.JsonCdc, X, boolean?]) { + describe(cast.label, () => { + test(`t.${cast.label}.asArgument(${input})`, () => { + if (shouldError) { + expect(() => cast.asArgument(input)).toThrow() + } else { + expect(cast.asArgument(input)).toStrictEqual(asArgument) + } + }) + test(`t.${cast.label}.asInjection(${input})`, () => { + expect(cast.asInjection(input)).toStrictEqual(asInjection) + }) + }) +} diff --git a/packages/types/src/types.js b/packages/types/src/types.ts similarity index 58% rename from packages/types/src/types.js rename to packages/types/src/types.ts index 543887322..17cbf4b92 100644 --- a/packages/types/src/types.js +++ b/packages/types/src/types.ts @@ -1,24 +1,64 @@ -import {log, LEVELS} from "@onflow/util-logger" +import {log} from "@onflow/util-logger" -const type = (label, asArgument, asInjection) => ({ +export type JsonCdc = { + type: L + value: T +} + +export interface PathValue { + domain: "storage" | "private" | "public" + identifier: string +} + +export interface ReferenceValue { + type: string + address: string +} + +export interface TypeDescriptor { + label: L + asArgument: (x: T) => JsonCdc + asInjection: (x: T) => T +} + +/** + * Creates a type descriptor for a given type + * @param label - The label for the type + * @param asArgument - A function that converts the type to a JsonCdcType + * @param asInjection - A function which returns the argument as is + * @returns A type descriptor + * @internal + */ +const typedef = ( + label: L, + asArgument: (x: T) => JsonCdc, + asInjection: (x: T) => T +): TypeDescriptor => ({ label, asArgument, - asInjection, + asInjection: (x: T) => { + log.deprecate({ + pkg: "@onflow/types", + subject: `Passing in ${label} as value for ${label}`, + message: `Going forward, use ${label} as value for ${label}.`, + }) + return asInjection(x) + }, }) -const isArray = d => Array.isArray(d) -const isObj = d => typeof d === "object" -const isNull = d => d == null -const isBoolean = d => typeof d === "boolean" -const isNumber = d => typeof d === "number" -const isInteger = d => Number.isInteger(d) -const isString = d => typeof d === "string" +const isArray = (d: unknown): d is T[] => Array.isArray(d) +const isObj = (d: unknown): d is object => typeof d === "object" +const isNull = (d: unknown): d is null | undefined => d == null +const isBoolean = (d: unknown): d is boolean => typeof d === "boolean" +const isNumber = (d: unknown): d is number => typeof d === "number" +const isInteger = (d: unknown): d is number => Number.isInteger(d) +const isString = (d: unknown): d is string => typeof d === "string" -const throwTypeError = msg => { +const throwTypeError = (msg: unknown): never => { throw new Error("Type Error: " + msg) } -const numberValuesDeprecationNotice = type => { +const numberValuesDeprecationNotice = (type: string) => { log.deprecate({ pkg: "@onflow/types", subject: `Passing in Number as value for ${type}`, @@ -28,15 +68,30 @@ const numberValuesDeprecationNotice = type => { }) } -export const Identity = type( - "Identity", - v => v, - v => v -) +let identityDeprecationShown = false +/** + * @deprecated will be removed in v2.0.0 + */ +export const Identity = { + label: "Identity", + asArgument: (v: T) => { + if (!identityDeprecationShown) { + log.deprecate({ + pkg: "@onflow/types", + subject: "Identity", + message: + "Identity type is deprecated and will be removed in v2.0.0. Please remove it from your code.", + }) + identityDeprecationShown = true + } + return v + }, + asInjection: (v: T) => v, +} -export const UInt = type( +export const UInt = typedef( "UInt", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt") return { @@ -50,14 +105,14 @@ export const UInt = type( value: v, } } - throwTypeError("Expected Positive Integer for type Unsigned Int") + return throwTypeError("Expected Positive Integer for type Unsigned Int") }, v => v ) -export const Int = type( +export const Int = typedef( "Int", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int") return { @@ -71,14 +126,14 @@ export const Int = type( value: v, } } - throwTypeError("Expected Integer for type Int") + return throwTypeError("Expected Integer for type Int") }, v => v ) -export const UInt8 = type( +export const UInt8 = typedef( "UInt8", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt8") return { @@ -92,14 +147,14 @@ export const UInt8 = type( value: v, } } - throwTypeError("Expected integer for UInt8") + return throwTypeError("Expected integer for UInt8") }, v => v ) -export const Int8 = type( +export const Int8 = typedef( "Int8", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int8") return { @@ -113,14 +168,14 @@ export const Int8 = type( value: v, } } - throwTypeError("Expected positive integer for Int8") + return throwTypeError("Expected positive integer for Int8") }, v => v ) -export const UInt16 = type( +export const UInt16 = typedef( "UInt16", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt16") return { @@ -134,14 +189,14 @@ export const UInt16 = type( value: v, } } - throwTypeError("Expected integer for UInt16") + return throwTypeError("Expected integer for UInt16") }, v => v ) -export const Int16 = type( +export const Int16 = typedef( "Int16", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int16") return { @@ -155,14 +210,14 @@ export const Int16 = type( value: v, } } - throwTypeError("Expected positive integer for Int16") + return throwTypeError("Expected positive integer for Int16") }, v => v ) -export const UInt32 = type( +export const UInt32 = typedef( "UInt32", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt32") return { @@ -176,14 +231,14 @@ export const UInt32 = type( value: v, } } - throwTypeError("Expected integer for UInt32") + return throwTypeError("Expected integer for UInt32") }, v => v ) -export const Int32 = type( +export const Int32 = typedef( "Int32", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int32") return { @@ -197,14 +252,14 @@ export const Int32 = type( value: v, } } - throwTypeError("Expected positive integer for Int32") + return throwTypeError("Expected positive integer for Int32") }, v => v ) -export const UInt64 = type( +export const UInt64 = typedef( "UInt64", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt64") return { @@ -218,14 +273,14 @@ export const UInt64 = type( value: v, } } - throwTypeError("Expected integer for UInt64") + return throwTypeError("Expected integer for UInt64") }, v => v ) -export const Int64 = type( +export const Int64 = typedef( "Int64", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int64") return { @@ -239,14 +294,14 @@ export const Int64 = type( value: v, } } - throwTypeError("Expected positive integer for Int64") + return throwTypeError("Expected positive integer for Int64") }, v => v ) -export const UInt128 = type( +export const UInt128 = typedef( "UInt128", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt128") return { @@ -260,14 +315,14 @@ export const UInt128 = type( value: v, } } - throwTypeError("Expected integer for UInt128") + return throwTypeError("Expected integer for UInt128") }, v => v ) -export const Int128 = type( +export const Int128 = typedef( "Int128", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int128") return { @@ -281,14 +336,14 @@ export const Int128 = type( value: v, } } - throwTypeError("Expected positive integer for Int128") + return throwTypeError("Expected positive integer for Int128") }, v => v ) -export const UInt256 = type( +export const UInt256 = typedef( "UInt256", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("UInt256") return { @@ -302,14 +357,14 @@ export const UInt256 = type( value: v, } } - throwTypeError("Expected integer for UInt256") + return throwTypeError("Expected integer for UInt256") }, v => v ) -export const Int256 = type( +export const Int256 = typedef( "Int256", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Int256") return { @@ -323,14 +378,14 @@ export const Int256 = type( value: v, } } - throwTypeError("Expected integer for Int256") + return throwTypeError("Expected integer for Int256") }, v => v ) -export const Word8 = type( +export const Word8 = typedef( "Word8", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Word8") return { @@ -344,14 +399,14 @@ export const Word8 = type( value: v, } } - throwTypeError("Expected positive number for Word8") + return throwTypeError("Expected positive number for Word8") }, v => v ) -export const Word16 = type( +export const Word16 = typedef( "Word16", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Word16") return { @@ -365,14 +420,14 @@ export const Word16 = type( value: v, } } - throwTypeError("Expected positive number for Word16") + return throwTypeError("Expected positive number for Word16") }, v => v ) -export const Word32 = type( +export const Word32 = typedef( "Word32", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Word32") return { @@ -386,14 +441,14 @@ export const Word32 = type( value: v, } } - throwTypeError("Expected positive number for Word32") + return throwTypeError("Expected positive number for Word32") }, v => v ) -export const Word64 = type( +export const Word64 = typedef( "Word64", - v => { + (v: number | string) => { if (isNumber(v) && isInteger(v)) { numberValuesDeprecationNotice("Word64") return { @@ -407,7 +462,7 @@ export const Word64 = type( value: v, } } - throwTypeError("Expected positive number for Word64") + return throwTypeError("Expected positive number for Word64") }, v => v ) @@ -421,18 +476,18 @@ const UFix64AndFix64NumberDeprecationNotice = () => { }) } -export const UFix64 = type( +export const UFix64 = typedef( "UFix64", - v => { + (v: number | string) => { if (isString(v)) { const vParts = v.split(".") if (vParts.length !== 2) { - throwTypeError( + return throwTypeError( `Expected one decimal but found ${vParts.length} in the [U]Fix64 value. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers` ) } if (vParts[1].length == 0 || vParts[1].length > 8) { - throwTypeError( + return throwTypeError( `Expected at least one digit, and at most 8 digits following the decimal of the [U]Fix64 value but found ${vParts[1].length} digits. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers` ) } @@ -452,23 +507,23 @@ export const UFix64 = type( value: v.toString(), } } - throwTypeError("Expected String for UFix64") + return throwTypeError("Expected String for UFix64") }, v => v ) -export const Fix64 = type( +export const Fix64 = typedef( "Fix64", - v => { + (v: number | string) => { if (isString(v)) { const vParts = v.split(".") if (vParts.length !== 2) { - throwTypeError( + return throwTypeError( `Expected one decimal but found ${vParts.length} in the [U]Fix64 value. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers` ) } if (vParts[1].length == 0 || vParts[1].length > 8) { - throwTypeError( + return throwTypeError( `Expected at least one digit, and at most 8 digits following the decimal of the [U]Fix64 value but found ${vParts[1].length} digits. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers` ) } @@ -488,102 +543,107 @@ export const Fix64 = type( value: v.toString(), } } - throwTypeError("Expected String for Fix64") + return throwTypeError("Expected String for Fix64") }, v => v ) -export const String = type( +export const String = typedef( "String", - v => { + (v: string) => { if (isString(v)) return { type: "String", value: v, } - throwTypeError("Expected String for type String") + return throwTypeError("Expected String for type String") }, v => v ) -export const Character = type( +export const Character = typedef( "Character", - v => { + (v: string) => { if (isString(v)) return { type: "Character", value: v, } - throwTypeError("Expected Character for type Character") + return throwTypeError("Expected Character for type Character") }, v => v ) -export const Bool = type( +export const Bool = typedef( "Bool", - v => { + (v: boolean) => { if (isBoolean(v)) return { type: "Bool", value: v, } - throwTypeError("Expected Boolean for type Bool") + return throwTypeError("Expected Boolean for type Bool") }, v => v ) -export const Address = type( +export const Address = typedef( "Address", - v => { + (v: string) => { if (isString(v)) return { type: "Address", value: v, } - throwTypeError("Expected Address for type Address") + return throwTypeError("Expected Address for type Address") }, v => v ) -export const Void = type( +export const Void = typedef( "Void", - v => { + (v?: null) => { if (!v || isNull(v)) return { type: "Void", + value: null, // so that it confroms to JsonCdcType interface } - throwTypeError("Expected Void for type Void") + return throwTypeError("Expected Void for type Void") }, v => v ) -export const Optional = children => - type( +export const Optional = ( + children: TypeDescriptor +) => + typedef( "Optional", - v => ({ + (v?: T | null) => ({ type: "Optional", value: isNull(v) ? null : children.asArgument(v), }), v => v ) -export const Reference = type( +export const Reference = typedef( "Reference", - v => { + (v: ReferenceValue) => { if (isObj(v)) return { type: "Reference", value: v, } - throwTypeError("Expected Object for type Reference") + return throwTypeError("Expected Object for type Reference") }, v => v ) -export const _Array = (children = []) => - type( +export const _Array = ( + children: TypeDescriptor[] | TypeDescriptor = [] +) => + typedef( "Array", - v => { + (v: T[]) => { return { type: "Array", value: isArray(children) @@ -596,39 +656,63 @@ export const _Array = (children = []) => export {_Array as Array} -export const Dictionary = (children = []) => - type( +// TODO : Fix types. Think about cases... dont think children should ever be array... not sure +export const Dictionary = ( + children: + | { + key: TypeDescriptor + value: TypeDescriptor + }[] + | { + key: TypeDescriptor + value: TypeDescriptor + } = [] +) => + typedef( "Dictionary", - v => { + (v: {key: A; value: D}[] | {key: A; value: D}) => { + const vIsArray = isArray(v) + const childrenIsArray = isArray(children) + if (isObj(v)) return { type: "Dictionary", - value: isArray(children) - ? children.map((c, i) => ({ - key: c.key.asArgument(v[i].key), - value: c.value.asArgument(v[i].value), - })) - : isArray(v) - ? v.map(x => ({ - key: children.key.asArgument(x.key), - value: children.value.asArgument(x.value), - })) - : [ - { - key: children.key.asArgument(v.key), - value: children.value.asArgument(v.value), - }, - ], + value: + childrenIsArray && vIsArray + ? children.map((c, i) => ({ + key: c.key.asArgument(v[i].key), + value: c.value.asArgument(v[i].value), + })) + : vIsArray && !childrenIsArray + ? v.map(x => ({ + key: children.key.asArgument(x.key), + value: children.value.asArgument(x.value), + })) + : !vIsArray && !childrenIsArray + ? [ + { + key: children.key.asArgument(v.key), + value: children.value.asArgument(v.value), + }, + ] + : throwTypeError( + "Invalid arguments for Dictionary. Expected an of array of key/value pairs" + ), } - throwTypeError("Expected Object for type Dictionary") + return throwTypeError("Expected Object for type Dictionary") }, v => v ) -export const Event = (id, fields = []) => - type( +export const Event = ( + id: string, + fields: + | {value: TypeDescriptor}[] + | {value: TypeDescriptor} = [] +) => + typedef( "Event", - v => { + (v: {fields: {name: string; value: T}[]}) => { if (isObj(v)) return { type: "Event", @@ -645,15 +729,20 @@ export const Event = (id, fields = []) => })), }, } - throwTypeError("Expected Object for type Event") + return throwTypeError("Expected Object for type Event") }, v => v ) -export const Resource = (id, fields = []) => - type( +export const Resource = ( + id: string, + fields: + | {value: TypeDescriptor}[] + | {value: TypeDescriptor} = [] +) => + typedef( "Resource", - v => { + (v: {fields: {name: string; value: T}[]}) => { if (isObj(v)) return { type: "Resource", @@ -670,15 +759,20 @@ export const Resource = (id, fields = []) => })), }, } - throwTypeError("Expected Object for type Resource") + return throwTypeError("Expected Object for type Resource") }, v => v ) -export const Struct = (id, fields = []) => - type( +export const Struct = ( + id: string, + fields: + | {value: TypeDescriptor}[] + | {value: TypeDescriptor} = [] +) => + typedef( "Struct", - v => { + (v: {fields: {name: string; value: T}[]}) => { if (isObj(v)) return { type: "Struct", @@ -695,15 +789,20 @@ export const Struct = (id, fields = []) => })), }, } - throwTypeError("Expected Object for type Struct") + return throwTypeError("Expected Object for type Struct") }, v => v ) -export const Enum = (id, fields = []) => - type( +export const Enum = ( + id: string, + fields: + | {value: TypeDescriptor}[] + | {value: TypeDescriptor} = [] +) => + typedef( "Enum", - v => { + (v: {fields: {name: string; value: T}[]}) => { if (isObj(v)) return { type: "Enum", @@ -720,17 +819,17 @@ export const Enum = (id, fields = []) => })), }, } - throwTypeError("Expected Object for type Enum") + return throwTypeError("Expected Object for type Enum") }, v => v ) -export const Path = type( +export const Path = typedef( "Path", - v => { + (v: PathValue) => { if (isObj(v)) { if (!isString(v.domain)) { - throwTypeError( + return throwTypeError( `Expected a string for the Path domain but found ${v.domain}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path` ) } @@ -742,13 +841,13 @@ export const Path = type( v.domain === "public" ) ) { - throwTypeError( + return throwTypeError( `Expected either "storage", "private" or "public" as the Path domain but found ${v.domain}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path` ) } if (!isString(v.identifier)) { - throwTypeError( + return throwTypeError( `Expected a string for the Path identifier but found ${v.identifier}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path` ) } @@ -761,7 +860,7 @@ export const Path = type( }, } } - throwTypeError("Expected Object for type Path") + return throwTypeError("Expected Object for type Path") }, v => v ) diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/types/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/util-actor/.babelrc b/packages/util-actor/.babelrc index 67fc2886b..f57936a43 100644 --- a/packages/util-actor/.babelrc +++ b/packages/util-actor/.babelrc @@ -2,6 +2,7 @@ "presets": [ [ "@babel/preset-env" - ] + ], + "@babel/preset-typescript" ] } diff --git a/packages/util-actor/.eslintrc.json b/packages/util-actor/.eslintrc.json new file mode 100644 index 000000000..e26aed124 --- /dev/null +++ b/packages/util-actor/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "@typescript-eslint/no-explicit-any": "off" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-actor/CHANGELOG.md b/packages/util-actor/CHANGELOG.md index c01689dd0..5f7140833 100644 --- a/packages/util-actor/CHANGELOG.md +++ b/packages/util-actor/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/util-actor +## 1.3.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1761](https://github.com/onflow/fcl-js/pull/1761) [`92b966d3`](https://github.com/onflow/fcl-js/commit/92b966d39936ba0a90629ee320e62e4fed5d2296) Thanks [@jribbink](https://github.com/jribbink)! - Enhance TS support for @onflow/util-actor + +## 1.3.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.2.0 ### Minor Changes diff --git a/packages/util-actor/jest.config.ts b/packages/util-actor/jest.config.ts new file mode 100644 index 000000000..22291c790 --- /dev/null +++ b/packages/util-actor/jest.config.ts @@ -0,0 +1,8 @@ +import type {Config} from 'jest'; + +const config: Config = { + verbose: true, + preset: "ts-jest", +}; + +export default config; \ No newline at end of file diff --git a/packages/util-actor/package.json b/packages/util-actor/package.json index ce51944fd..5284fb821 100644 --- a/packages/util-actor/package.json +++ b/packages/util-actor/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-actor", - "version": "1.2.0", + "version": "1.3.0", "description": "A mechanism for forcing order/transitions of scoped async state", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,22 +13,30 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, "dependencies": { "@babel/runtime": "^7.18.6", "queue-microtask": "1.2.3" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/actor.js", "module": "dist/actor.module.js", "unpkg": "dist/actor.umd.js", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "fcl-bundle", "test:watch": "jest --watch", - "start": "fcl-bundle --watch" + "start": "fcl-bundle --watch", + "lint": "eslint src --ext .ts" } } diff --git a/packages/util-actor/src/index.js b/packages/util-actor/src/index.js deleted file mode 100644 index d697091dd..000000000 --- a/packages/util-actor/src/index.js +++ /dev/null @@ -1,205 +0,0 @@ -import {mailbox as createMailbox} from "./mailbox" -import queueMicrotask from "queue-microtask" - -export const INIT = "INIT" -export const SUBSCRIBE = "SUBSCRIBE" -export const UNSUBSCRIBE = "UNSUBSCRIBE" -export const UPDATED = "UPDATED" -export const SNAPSHOT = "SNAPSHOT" -export const EXIT = "EXIT" -export const TERMINATE = "TERMINATE" - -const root = - (typeof self === "object" && self.self === self && self) || - (typeof global === "object" && global.global === global && global) || - (typeof window === "object" && window.window === window && window) - -root.FCL_REGISTRY = root.FCL_REGISTRY == null ? {} : root.FCL_REGISTRY -var pid = 0b0 - -const DEFAULT_TIMEOUT = 5000 -const DEFAULT_TAG = "---" -export const send = (addr, tag, data, opts = {}) => - new Promise((reply, reject) => { - const expectReply = opts.expectReply || false - const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT - - if (expectReply && timeout) { - setTimeout( - () => - reject(new Error(`Timeout: ${timeout}ms passed without a response.`)), - timeout - ) - } - - const payload = { - to: addr, - from: opts.from, - tag, - data, - timeout, - reply, - reject, - } - - try { - root.FCL_REGISTRY[addr] && - root.FCL_REGISTRY[addr].mailbox.deliver(payload) - if (!expectReply) reply(true) - } catch (error) { - console.error( - "FCL.Actor -- Could Not Deliver Message", - payload, - root.FCL_REGISTRY[addr], - error - ) - } - }) - -export const kill = addr => { - delete root.FCL_REGISTRY[addr] -} - -const fromHandlers = - (handlers = {}) => - async ctx => { - if (typeof handlers[INIT] === "function") await handlers[INIT](ctx) - __loop: while (1) { - const letter = await ctx.receive() - try { - if (letter.tag === EXIT) { - if (typeof handlers[TERMINATE] === "function") { - await handlers[TERMINATE](ctx, letter, letter.data || {}) - } - break __loop - } - await handlers[letter.tag](ctx, letter, letter.data || {}) - } catch (error) { - console.error(`${ctx.self()} Error`, letter, error) - } finally { - continue __loop - } - } - } - -export const spawn = (fn, addr = null) => { - if (addr == null) addr = ++pid - if (root.FCL_REGISTRY[addr] != null) return addr - - root.FCL_REGISTRY[addr] = { - addr, - mailbox: createMailbox(), - subs: new Set(), - kvs: {}, - error: null, - } - - const ctx = { - self: () => addr, - receive: () => root.FCL_REGISTRY[addr].mailbox.receive(), - send: (to, tag, data, opts = {}) => { - opts.from = addr - return send(to, tag, data, opts) - }, - sendSelf: (tag, data, opts) => { - if (root.FCL_REGISTRY[addr]) send(addr, tag, data, opts) - }, - broadcast: (tag, data, opts = {}) => { - opts.from = addr - for (let to of root.FCL_REGISTRY[addr].subs) send(to, tag, data, opts) - }, - subscribe: sub => sub != null && root.FCL_REGISTRY[addr].subs.add(sub), - unsubscribe: sub => sub != null && root.FCL_REGISTRY[addr].subs.delete(sub), - subscriberCount: () => root.FCL_REGISTRY[addr].subs.size, - hasSubs: () => !!root.FCL_REGISTRY[addr].subs.size, - put: (key, value) => { - if (key != null) root.FCL_REGISTRY[addr].kvs[key] = value - }, - get: (key, fallback) => { - const value = root.FCL_REGISTRY[addr].kvs[key] - return value == null ? fallback : value - }, - delete: key => { - delete root.FCL_REGISTRY[addr].kvs[key] - }, - update: (key, fn) => { - if (key != null) - root.FCL_REGISTRY[addr].kvs[key] = fn(root.FCL_REGISTRY[addr].kvs[key]) - }, - keys: () => { - return Object.keys(root.FCL_REGISTRY[addr].kvs) - }, - all: () => { - return root.FCL_REGISTRY[addr].kvs - }, - where: pattern => { - return Object.keys(root.FCL_REGISTRY[addr].kvs).reduce((acc, key) => { - return pattern.test(key) - ? {...acc, [key]: root.FCL_REGISTRY[addr].kvs[key]} - : acc - }, {}) - }, - merge: (data = {}) => { - Object.keys(data).forEach( - key => (root.FCL_REGISTRY[addr].kvs[key] = data[key]) - ) - }, - fatalError: error => { - root.FCL_REGISTRY[addr].error = error - for (let to of root.FCL_REGISTRY[addr].subs) send(to, UPDATED) - }, - } - - if (typeof fn === "object") fn = fromHandlers(fn) - - queueMicrotask(async () => { - await fn(ctx) - kill(addr) - }) - - return addr -} - -// Returns an unsubscribe function -// A SUBSCRIBE handler will need to be created to handle the subscription event -// -// [SUBSCRIBE]: (ctx, letter) => { -// ctx.subscribe(letter.from) -// ctx.send(letter.from, UPDATED, ctx.all()) -// } -// -export function subscriber(address, spawnFn, callback) { - spawnFn(address) - const EXIT = "@EXIT" - const self = spawn(async ctx => { - ctx.send(address, SUBSCRIBE) - while (1) { - const letter = await ctx.receive() - const error = root.FCL_REGISTRY[address].error - if (letter.tag === EXIT) { - ctx.send(address, UNSUBSCRIBE) - return - } - if (error) { - callback(null, error) - ctx.send(address, UNSUBSCRIBE) - return - } - - callback(letter.data, null) - } - }) - return () => send(self, EXIT) -} - -// Returns a promise that returns a result -// A SNAPSHOT handler will need to be created to handle the snapshot event -// -// [SNAPSHOT]: (ctx, letter) => { -// letter.reply(ctx.all()) -// } -// -export function snapshoter(address, spawnFn) { - spawnFn(address) - return send(address, SNAPSHOT, null, {expectReply: true, timeout: 0}) -} diff --git a/packages/util-actor/src/index.test.js b/packages/util-actor/src/index.test.ts similarity index 86% rename from packages/util-actor/src/index.test.js rename to packages/util-actor/src/index.test.ts index 5efce9f47..7bc79608c 100644 --- a/packages/util-actor/src/index.test.js +++ b/packages/util-actor/src/index.test.ts @@ -1,4 +1,4 @@ -import {spawn, send, kill} from "./" +import {spawn, send, kill, ActorContext} from "./" const COUNT = "COUNT" const DUMP = "DUMP" @@ -8,7 +8,7 @@ const UPDATED = "UPDATED" const SUBSCRIBE = "SUBSCRIBE" const UNSUBSCRIBE = "UNSUBSCRIBE" -const counterLogic = async ctx => { +const counterLogic = async (ctx: ActorContext) => { ctx.put(COUNT, 0) __loop: while (1) { @@ -18,7 +18,7 @@ const counterLogic = async ctx => { switch (letter.tag) { case SUBSCRIBE: ctx.subscribe(letter.from) - ctx.send(letter.from, UPDATED, ctx.get(COUNT, 0)) + ctx.send(letter.from!, UPDATED, ctx.get(COUNT, 0)) continue __loop case UNSUBSCRIBE: @@ -44,11 +44,12 @@ const counterLogic = async ctx => { } } -const counter = name => spawn(counterLogic, name) -const dump = addr => send(addr, DUMP, null, {expectReply: true, timeout: 100}) -const inc = (addr, delta = 1) => send(addr, INC, {delta}) +const counter = (name: string) => spawn(counterLogic, name) +const dump = (addr: string) => + send(addr, DUMP, null, {expectReply: true, timeout: 100}) +const inc = (addr: string, delta = 1) => send(addr, INC, {delta}) -const subscribe = (addr, callback) => { +const subscribe = (addr: string, callback: (data: any) => void) => { const EXIT = "@EXIT" const self = spawn(async ctx => { ctx.send(addr, SUBSCRIBE) @@ -72,13 +73,13 @@ const idle = async () => new Promise(resolve => setTimeout(resolve, 0)) describe("golden path", () => { describe("init, send, receive", () => { test("rpc initial value", async () => { - const c = counter() + const c = counter("") expect(await dump(c)).toBe(0) kill(c) }) test("send message and rpc value", async () => { - const c = counter() + const c = counter("value") inc(c, 5) expect(await dump(c)).toBe(5) kill(c) @@ -152,8 +153,8 @@ describe("golden path", () => { test("actors with same name only spawn once", async () => { const fn = jest.fn() - const c1 = spawn(fn, "foo") - const c2 = spawn(fn, "foo") + const c1 = spawn(fn, 0) + const c2 = spawn(fn, 0) await idle() expect(c1).toBe(c2) diff --git a/packages/util-actor/src/index.ts b/packages/util-actor/src/index.ts new file mode 100644 index 000000000..b315f4da8 --- /dev/null +++ b/packages/util-actor/src/index.ts @@ -0,0 +1,312 @@ +import {mailbox as createMailbox, type IMailbox} from "./mailbox" + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const queueMicrotask = require("queue-microtask") + +export const INIT = "INIT" +export const SUBSCRIBE = "SUBSCRIBE" +export const UNSUBSCRIBE = "UNSUBSCRIBE" +export const UPDATED = "UPDATED" +export const SNAPSHOT = "SNAPSHOT" +export const EXIT = "EXIT" +export const TERMINATE = "TERMINATE" +const DUMP = "DUMP" +const INC = "INC" +const KEYS = "KEYS" + +interface IRegistryRecord { + addr: string + mailbox: IMailbox + subs: Set + kvs: Record + error: any +} +interface IRoot { + FCL_REGISTRY: Record | null +} + +export type ActorContext = ReturnType + +export type Letter = { + to: string + from?: string + tag: string + data: any + timeout: number + reply: (data: any) => void + reject: (error: any) => void +} +export type HandlerFn = ( + ctx: ActorContext, + letter: Letter, + data: any +) => Promise | void +export type SpawnFn = (address?: string) => void +export interface ActorHandlers { + [INIT]?: (ctx: ActorContext) => Promise | void + [SUBSCRIBE]?: HandlerFn + [UNSUBSCRIBE]?: HandlerFn + [UPDATED]?: HandlerFn + [SNAPSHOT]?: HandlerFn + [EXIT]?: HandlerFn + [TERMINATE]?: HandlerFn + [DUMP]?: HandlerFn + [INC]?: HandlerFn + [KEYS]?: HandlerFn + [key: string]: HandlerFn | undefined +} + +const root: IRoot = (typeof self === "object" && + self.self === self && + (self as unknown as IRoot)) || + (typeof global === "object" && + global.global === global && + (global as unknown as IRoot)) || + (typeof window === "object" && + window.window === window && + (window as unknown as IRoot)) || {FCL_REGISTRY: null} + +root.FCL_REGISTRY = root.FCL_REGISTRY == null ? {} : root.FCL_REGISTRY + +const FCL_REGISTRY = root.FCL_REGISTRY +let pid = 0b0 + +const DEFAULT_TIMEOUT = 5000 + +export function send( + addr: string, + tag: keyof Handlers & string, + data?: Record | null, + opts?: {expectReply?: true; timeout?: number; from?: string} +): Promise +export function send( + addr: string, + tag: keyof Handlers & string, + data?: Record | null, + opts?: {expectReply?: false; timeout?: number; from?: string} +): Promise +export function send( + addr: string, + tag: keyof Handlers & string, + data?: Record | null, + opts: {expectReply?: boolean; timeout?: number; from?: string} = { + expectReply: false, + } +): Promise { + return new Promise((resolve, reject) => { + const expectReply = opts.expectReply || false + const timeout = opts.timeout != null ? opts.timeout : DEFAULT_TIMEOUT + + if (expectReply && timeout) { + setTimeout( + () => + reject(new Error(`Timeout: ${timeout}ms passed without a response.`)), + timeout + ) + } + + const payload = { + to: addr, + from: opts.from, + tag, + data, + timeout, + reply: resolve, + reject, + } + + try { + if (FCL_REGISTRY[addr]) { + FCL_REGISTRY[addr].mailbox.deliver(payload) + } + if (!expectReply) { + resolve(true) + } + } catch (error) { + console.error( + "FCL.Actor -- Could Not Deliver Message", + payload, + FCL_REGISTRY[addr], + error + ) + reject(error) + } + }) +} + +export const kill = (addr: string) => { + delete FCL_REGISTRY[addr] +} + +const fromHandlers = + (handlers: Handlers) => + async (ctx: ActorContext) => { + if (typeof handlers[INIT] === "function") await handlers[INIT](ctx) + __loop: while (1) { + const letter = await ctx.receive() + try { + if (letter.tag === EXIT) { + if (typeof handlers[TERMINATE] === "function") { + await handlers[TERMINATE](ctx, letter, letter.data || {}) + } + break __loop + } + await handlers[letter.tag as any]?.(ctx, letter, letter.data || {}) + } catch (error) { + console.error(`${ctx.self()} Error`, letter, error) + } finally { + continue __loop + } + } + } + +const parseAddr = (addr: string | number | null): string => { + if (addr == null) { + return String(++pid) + } + return String(addr) +} + +export const spawn = ( + fnOrHandlers: ((ctx: ActorContext) => Promise) | Handlers, + rawAddr: string | number | null = null +) => { + const addr = parseAddr(rawAddr) + if (FCL_REGISTRY[addr] != null) return addr + + FCL_REGISTRY[addr] = { + addr, + mailbox: createMailbox(), + subs: new Set(), + kvs: {}, + error: null, + } + + const ctx = createCtx(addr) + + let fn: (ctx: ActorContext) => Promise + if (typeof fnOrHandlers === "object") + fn = fromHandlers(fnOrHandlers) + else fn = fnOrHandlers + + queueMicrotask(async () => { + await fn(ctx) + kill(addr) + }) + + return addr +} + +const createCtx = (addr: string) => ({ + self: () => addr, + receive: () => FCL_REGISTRY[addr].mailbox.receive(), + send: ( + to: string, + tag: string, + data?: any, + opts: Record = {} + ) => { + opts.from = addr + return send(to, tag, data, opts) + }, + sendSelf: (tag: string, data?: any, opts: Record = {}) => { + if (FCL_REGISTRY[addr]) send(addr, tag, data, opts) + }, + broadcast: (tag: string, data: any, opts: Record = {}) => { + opts.from = addr + for (const to of FCL_REGISTRY[addr].subs) send(to, tag, data, opts) + }, + subscribe: (sub?: string | null) => + sub != null && FCL_REGISTRY[addr].subs.add(sub), + unsubscribe: (sub?: string | null) => + sub != null && FCL_REGISTRY[addr].subs.delete(sub), + subscriberCount: () => FCL_REGISTRY[addr].subs.size, + hasSubs: () => !!FCL_REGISTRY[addr].subs.size, + put: (key: string, value: T) => { + if (key != null) FCL_REGISTRY[addr].kvs[key] = value + }, + get: (key: string, fallback: T | undefined = undefined) => { + const value = FCL_REGISTRY[addr].kvs[key] + return value == null ? fallback : value + }, + delete: (key: string) => { + delete FCL_REGISTRY[addr].kvs[key] + }, + update: (key: string, fn: (x: T) => U) => { + if (key != null) + FCL_REGISTRY[addr].kvs[key] = fn(FCL_REGISTRY[addr].kvs[key]) + }, + keys: () => { + return Object.keys(FCL_REGISTRY[addr].kvs) + }, + all: () => { + return FCL_REGISTRY[addr].kvs + }, + where: (pattern: RegExp) => { + return Object.keys(FCL_REGISTRY[addr].kvs).reduce((acc, key) => { + return pattern.test(key) + ? {...acc, [key]: FCL_REGISTRY[addr].kvs[key]} + : acc + }, {}) + }, + merge: (data: Record = {}) => { + Object.keys(data).forEach(key => (FCL_REGISTRY[addr].kvs[key] = data[key])) + }, + fatalError: (error: Error) => { + FCL_REGISTRY[addr].error = error + for (const to of FCL_REGISTRY[addr].subs) send(to, UPDATED) + }, +}) + +// Returns an unsubscribe function +// A SUBSCRIBE handler will need to be created to handle the subscription event +// +// [SUBSCRIBE]: (ctx, letter) => { +// ctx.subscribe(letter.from) +// ctx.send(letter.from, UPDATED, ctx.all()) +// } +// +export function subscriber( + address: string, + spawnFn: SpawnFn, + callback: (data: T | null, error: Error | null) => void +) { + spawnFn(address) + const self = spawn(async (ctx: ActorContext) => { + ctx.send(address, SUBSCRIBE) + while (1) { + const letter = await ctx.receive() + const error = FCL_REGISTRY[address].error + if (letter.tag === EXIT) { + ctx.send(address, UNSUBSCRIBE) + return + } + if (error) { + callback(null, error) + ctx.send(address, UNSUBSCRIBE) + return + } + + callback(letter.data, null) + } + }) + return () => send(self, EXIT) +} + +// Returns a promise that returns a result +// A SNAPSHOT handler will need to be created to handle the snapshot event +// +// [SNAPSHOT]: (ctx, letter) => { +// letter.reply(ctx.all()) +// } +// +export function snapshoter( + address: string, + spawnFn: SpawnFn +) { + spawnFn(address) + return send(address, SNAPSHOT, null, { + expectReply: true, + timeout: 0, + }) +} diff --git a/packages/util-actor/src/mailbox/index.js b/packages/util-actor/src/mailbox/index.js deleted file mode 100644 index ca1cd6be9..000000000 --- a/packages/util-actor/src/mailbox/index.js +++ /dev/null @@ -1,22 +0,0 @@ -export const mailbox = () => { - const queue = [] - var next - - return { - async deliver(msg) { - queue.push(msg) - if (next) { - next(queue.shift()) - next = undefined - } - }, - - receive() { - return new Promise(function innerReceive(resolve) { - const msg = queue.shift() - if (msg) return resolve(msg) - next = resolve - }) - }, - } -} diff --git a/packages/util-actor/src/mailbox/index.test.js b/packages/util-actor/src/mailbox/index.test.ts similarity index 51% rename from packages/util-actor/src/mailbox/index.test.js rename to packages/util-actor/src/mailbox/index.test.ts index 4d5a84c6a..cc85aa2dd 100644 --- a/packages/util-actor/src/mailbox/index.test.js +++ b/packages/util-actor/src/mailbox/index.test.ts @@ -9,8 +9,8 @@ test("send and receive", async () => { test("first in -- first out", async () => { const m = genMailbox() const msgx = ["A", "B", "C", "D", "E", "F"] - for (let msg of msgx) m.deliver(msg) - for (let msg of msgx) expect(await m.receive()).toBe(msg) + for (const msg of msgx) m.deliver(msg) + for (const msg of msgx) expect(await m.receive()).toBe(msg) }) test("many mailboxes", async () => { @@ -24,13 +24,13 @@ test("many mailboxes", async () => { const m3x = ["X", "Y", "Z"] const m4x = ["7", "8", "9"] - for (let msg of m1x) m1.deliver(msg) - for (let msg of m2x) m2.deliver(msg) - for (let msg of m3x) m3.deliver(msg) - for (let msg of m4x) m4.deliver(msg) + for (const msg of m1x) m1.deliver(msg) + for (const msg of m2x) m2.deliver(msg) + for (const msg of m3x) m3.deliver(msg) + for (const msg of m4x) m4.deliver(msg) - for (let msg of m1x) expect(await m1.receive()).toBe(msg) - for (let msg of m2x) expect(await m2.receive()).toBe(msg) - for (let msg of m3x) expect(await m3.receive()).toBe(msg) - for (let msg of m4x) expect(await m4.receive()).toBe(msg) + for (const msg of m1x) expect(await m1.receive()).toBe(msg) + for (const msg of m2x) expect(await m2.receive()).toBe(msg) + for (const msg of m3x) expect(await m3.receive()).toBe(msg) + for (const msg of m4x) expect(await m4.receive()).toBe(msg) }) diff --git a/packages/util-actor/src/mailbox/index.ts b/packages/util-actor/src/mailbox/index.ts new file mode 100644 index 000000000..4d9d4b715 --- /dev/null +++ b/packages/util-actor/src/mailbox/index.ts @@ -0,0 +1,26 @@ +export interface IMailbox { + deliver(msg: T): Promise + receive(): Promise +} +export const mailbox = (): IMailbox => { + const queue: T[] = [] + let next: ((msg: T) => void) | undefined + + return { + async deliver(msg: T) { + queue.push(msg) + if (next) { + next(queue.shift() as T) + next = undefined + } + }, + + receive(): Promise { + return new Promise(function innerReceive(resolve) { + const msg = queue.shift() + if (msg) return resolve(msg) + next = resolve + }) + }, + } +} diff --git a/packages/util-actor/tsconfig.json b/packages/util-actor/tsconfig.json new file mode 100644 index 000000000..ac6917898 --- /dev/null +++ b/packages/util-actor/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types" + } +} diff --git a/packages/util-address/.babelrc b/packages/util-address/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-address/.babelrc +++ b/packages/util-address/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-address/.eslintrc.json b/packages/util-address/.eslintrc.json index b5e57f0a6..79f65ebf2 100644 --- a/packages/util-address/.eslintrc.json +++ b/packages/util-address/.eslintrc.json @@ -6,22 +6,18 @@ "node": true }, "extends": [ - "plugin:jsdoc/recommended" - ], - "plugins": [ - "jsdoc" + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "ignorePatterns": ["**/dist/"], "rules": { - "jsdoc/require-jsdoc": [ - "error", - { - "publicOnly": true - } - ] + "@typescript-eslint/no-explicit-any": "off" } -} \ No newline at end of file +} diff --git a/packages/util-address/CHANGELOG.md b/packages/util-address/CHANGELOG.md index c014ddafa..5a07f5c82 100644 --- a/packages/util-address/CHANGELOG.md +++ b/packages/util-address/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/util-address +## 1.2.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/util-address/package.json b/packages/util-address/package.json index 19242e4e0..e03876f4f 100644 --- a/packages/util-address/package.json +++ b/packages/util-address/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-address", - "version": "1.1.0", + "version": "1.2.0", "description": "Flow JS SDK Util -- Address", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,24 +13,27 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@onflow/types": "^1.2.0", + "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.7.5", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/util-address.js", "module": "dist/util-address.module.js", "unpkg": "dist/util-address.umd.js", - "types": "types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", - "build:types": "tsc", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." diff --git a/packages/util-address/src/index.js b/packages/util-address/src/index.js deleted file mode 100644 index 38d51151d..000000000 --- a/packages/util-address/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @description Removes 0x from address if present - * @param {string} address - Flow address - * @returns {string} - Flow address without 0x prefix - */ - export function sansPrefix(address) { - if (address == null) return null - return address.replace(/^0x/, "").replace(/^Fx/, "") -} - -/** - * @description Adds 0x to address if not already present - * @param {string} address - Flow address - * @returns {string} - Flow address with 0x prefix - */ -export function withPrefix(address) { - if (address == null) return null - return "0x" + sansPrefix(address) -} - -/** - * @description Adds 0x to address if not already present - * @param {string} address - Flow address - * @returns {string} - Flow address with 0x prefix - */ -export function display(address) { - return withPrefix(address) -} diff --git a/packages/util-address/src/index.test.js b/packages/util-address/src/index.test.ts similarity index 100% rename from packages/util-address/src/index.test.js rename to packages/util-address/src/index.test.ts diff --git a/packages/util-address/src/index.ts b/packages/util-address/src/index.ts new file mode 100644 index 000000000..33e05de1a --- /dev/null +++ b/packages/util-address/src/index.ts @@ -0,0 +1,28 @@ +/** + * @description Removes 0x from address if present + * @param address - Flow address + * @returns Flow address without 0x prefix + */ +export function sansPrefix(address: string | null): string | null { + if (address == null) return null + return address.replace(/^0x/, "").replace(/^Fx/, "") +} + +/** + * @description Adds 0x to address if not already present + * @param address - Flow address + * @returns Flow address with 0x prefix + */ +export function withPrefix(address: string | null): string | null { + if (address == null) return null + return "0x" + sansPrefix(address) +} + +/** + * @description Adds 0x to address if not already present + * @param address - Flow address + * @returns Flow address with 0x prefix + */ +export function display(address: string | null): string | null { + return withPrefix(address) +} diff --git a/packages/util-address/tsconfig.json b/packages/util-address/tsconfig.json index 6bfcb0e73..88be905eb 100644 --- a/packages/util-address/tsconfig.json +++ b/packages/util-address/tsconfig.json @@ -1,25 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - "types" : ["node"], - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, } } \ No newline at end of file diff --git a/packages/util-encode-key/.babelrc b/packages/util-encode-key/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-encode-key/.babelrc +++ b/packages/util-encode-key/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-encode-key/.eslintrc.json b/packages/util-encode-key/.eslintrc.json index b5e57f0a6..79f65ebf2 100644 --- a/packages/util-encode-key/.eslintrc.json +++ b/packages/util-encode-key/.eslintrc.json @@ -6,22 +6,18 @@ "node": true }, "extends": [ - "plugin:jsdoc/recommended" - ], - "plugins": [ - "jsdoc" + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "ignorePatterns": ["**/dist/"], "rules": { - "jsdoc/require-jsdoc": [ - "error", - { - "publicOnly": true - } - ] + "@typescript-eslint/no-explicit-any": "off" } -} \ No newline at end of file +} diff --git a/packages/util-encode-key/CHANGELOG.md b/packages/util-encode-key/CHANGELOG.md index a2a08e51f..d21f5541f 100644 --- a/packages/util-encode-key/CHANGELOG.md +++ b/packages/util-encode-key/CHANGELOG.md @@ -1,5 +1,31 @@ # @onflow/util-encode-key +## 1.2.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript + +### Patch Changes + +- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477)]: + - @onflow/util-invariant@1.2.0 + - @onflow/rlp@1.2.0 + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + +### Patch Changes + +- Updated dependencies []: + - @onflow/util-invariant@1.2.0-alpha.0 + - @onflow/rlp@1.2.0-alpha.0 + ## 1.1.0 ### Minor Changes diff --git a/packages/util-encode-key/package.json b/packages/util-encode-key/package.json index 8e8012eb7..ba977c2ab 100644 --- a/packages/util-encode-key/package.json +++ b/packages/util-encode-key/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-encode-key", - "version": "1.1.0", + "version": "1.2.0", "description": "Flow JS SDK Util -- Encode Key", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,31 +13,34 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@onflow/types": "^1.2.0", + "@types/jest": "^29.5.3", "@types/node": "^18.13.0", - "eslint": "^8.33.0", - "eslint-plugin-jsdoc": "^39.8.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0", "typescript": "^4.9.5" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/util-encode-key.js", "module": "dist/util-encode-key.module.js", "unpkg": "dist/util-encode-key.umd.js", - "types": "types/index.d.ts", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", "build": "npm run lint && fcl-bundle", - "build:types": "tsc", "test:watch": "jest --watch", "start": "fcl-bundle --watch", "lint": "eslint ." }, "dependencies": { "@babel/runtime": "^7.18.6", - "@onflow/rlp": "^1.1.0", - "@onflow/util-invariant": "^1.1.0" + "@onflow/rlp": "^1.2.0", + "@onflow/util-invariant": "^1.2.0" } } diff --git a/packages/util-encode-key/src/__snapshots__/index.test.js.snap b/packages/util-encode-key/src/__snapshots__/index.test.ts.snap similarity index 100% rename from packages/util-encode-key/src/__snapshots__/index.test.js.snap rename to packages/util-encode-key/src/__snapshots__/index.test.ts.snap diff --git a/packages/util-encode-key/src/index.test.js b/packages/util-encode-key/src/index.test.ts similarity index 69% rename from packages/util-encode-key/src/index.test.js rename to packages/util-encode-key/src/index.test.ts index fed721890..220e69b7b 100644 --- a/packages/util-encode-key/src/index.test.js +++ b/packages/util-encode-key/src/index.test.ts @@ -1,10 +1,4 @@ -import { - encodeKey, - ECDSA_P256, - ECDSA_secp256k1, - SHA2_256, - SHA3_256, -} from "./index.js" +import {encodeKey, ECDSA_P256, ECDSA_secp256k1, SHA2_256, SHA3_256} from "./" const PUBLIC_KEYS = [ "0bfcd8790c3ce88f3fac9d4bd23514f48bf0cdd1f6c3c8bdf87b11489b1bbeca1ef805ec2ee76451e9bdb265284f78febaeacbc8b0827e0a7baafee4e655d0b5", @@ -18,10 +12,10 @@ const HASHINGS = [SHA2_256, SHA3_256] const WEIGHTS = [0, 32, 512, 1000] -for (let [key_index, key] of PUBLIC_KEYS.entries()) { - for (let [curve_index, curve] of CURVES.entries()) { - for (let [hash_index, hash] of HASHINGS.entries()) { - for (let [weight_index, weight] of WEIGHTS.entries()) { +for (const [key_index, key] of PUBLIC_KEYS.entries()) { + for (const [curve_index, curve] of CURVES.entries()) { + for (const [hash_index, hash] of HASHINGS.entries()) { + for (const [weight_index, weight] of WEIGHTS.entries()) { test(`key:${key_index} curve:${curve_index} hash:${hash_index} weight:${weight_index}`, () => { expect(encodeKey(key, curve, hash, weight)).toMatchSnapshot() }) diff --git a/packages/util-encode-key/src/index.js b/packages/util-encode-key/src/index.ts similarity index 76% rename from packages/util-encode-key/src/index.js rename to packages/util-encode-key/src/index.ts index 6c6b98b5b..9ba359091 100644 --- a/packages/util-encode-key/src/index.js +++ b/packages/util-encode-key/src/index.ts @@ -3,48 +3,23 @@ import {encode} from "@onflow/rlp" // Curves -/** - * @type {number} - */ export const ECDSA_P256 = 2 - -/** - * @type {number} - */ export const ECDSA_secp256k1 = 3 - -/** - * @type {Set} - * @private - */ const VALID_CURVES = new Set([ECDSA_P256, ECDSA_secp256k1]) // Hashing -/** - * @type {number} - */ export const SHA2_256 = 1 - -/** - * @type {number} - */ export const SHA3_256 = 3 - -/** - * @type {Set} - * @private - */ const VALID_HASHINGS = new Set([SHA2_256, SHA3_256]) /** * Encodes a key into a hex string - * - * @param {string} key - The key to encode (DER Hex) - * @param {number} curve - The curve Flow needs to use with your key [ECDSA_P256|ECDSA_secp256k1] - * @param {number} hash - The hashing algorythm Flow needs to use with your key [SHA2_256|SHA3_256] - * @param {number} weight - The weight you want this key to have [Range: 0..1000] - * @returns {string} - The encoded key + * @param key - The key to encode (DER Hex) + * @param curve - The curve Flow needs to use with your key [ECDSA_P256|ECDSA_secp256k1] + * @param hash - The hashing algorythm Flow needs to use with your key [SHA2_256|SHA3_256] + * @param weight - The weight you want this key to have [Range: 0..1000] + * @returns The encoded key * @throws {Error} - Throws if the key is not a string * @throws {Error} - Throws if the key is not in the correct format * @throws {Error} - Throws if the curve is not a number @@ -56,7 +31,12 @@ const VALID_HASHINGS = new Set([SHA2_256, SHA3_256]) * import {encodeKey, ECDSA_P256, SHA3_256} from "@onflow/util-encode-key" * encodeKey("aabbccdd", ECDSA_P256, SHA3_256, 1000) // => "aabbccdd0201000" */ -export function encodeKey(key, curve, hash, weight = 1000) { +export function encodeKey( + key: string, + curve: number, + hash: number, + weight = 1000 +): string { invariant( typeof key === "string", "encodeKey(key, curve, hash, weight) -- invalid key (expecting type of string)" @@ -87,4 +67,4 @@ export function encodeKey(key, curve, hash, weight = 1000) { ) return encode([Buffer.from(key, "hex"), curve, hash, weight]).toString("hex") -} \ No newline at end of file +} diff --git a/packages/util-encode-key/tsconfig.json b/packages/util-encode-key/tsconfig.json index 6bfcb0e73..88be905eb 100644 --- a/packages/util-encode-key/tsconfig.json +++ b/packages/util-encode-key/tsconfig.json @@ -1,25 +1,11 @@ { + "extends": "../../tsconfig", // Change this to match your project "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.js", - ], "compilerOptions": { - "types" : ["node"], - // Tells TypeScript to read JS files, as - // normally they are ignored as source files - "allowJs": true, - // Generate d.ts files - "declaration": true, - // This compiler run should - // only output d.ts files - "emitDeclarationOnly": true, // Types should go into this directory. // Removing this would place the .d.ts files // next to the .js files "outDir": "types", - // go to js file when using IDE functions like - // "Go to Definition" in VSCode - "declarationMap": false, } } \ No newline at end of file diff --git a/packages/util-invariant/.eslintrc.json b/packages/util-invariant/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-invariant/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-invariant/CHANGELOG.md b/packages/util-invariant/CHANGELOG.md index 826b3b5d4..862537414 100644 --- a/packages/util-invariant/CHANGELOG.md +++ b/packages/util-invariant/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/util-invariant +## 1.2.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/util-invariant/package.json b/packages/util-invariant/package.json index c005edc92..986583aad 100644 --- a/packages/util-invariant/package.json +++ b/packages/util-invariant/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-invariant", - "version": "1.1.0", + "version": "1.2.0", "description": "Flow JS SDK Util -- Invariant", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,14 +13,21 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", - "@onflow/types": "^1.1.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@onflow/types": "^1.2.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/index.js", + "source": "src/index.ts", "main": "dist/util-invariant.js", "module": "dist/util-invariant.module.js", "unpkg": "dist/util-invariant.umd.js", + "types": "dist/index.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-invariant/src/index.test.js b/packages/util-invariant/src/index.test.ts similarity index 100% rename from packages/util-invariant/src/index.test.js rename to packages/util-invariant/src/index.test.ts diff --git a/packages/util-invariant/src/index.js b/packages/util-invariant/src/index.ts similarity index 55% rename from packages/util-invariant/src/index.js rename to packages/util-invariant/src/index.ts index d453e9406..0fedc85b2 100644 --- a/packages/util-invariant/src/index.js +++ b/packages/util-invariant/src/index.ts @@ -1,17 +1,16 @@ /** * Asserts fact is true, otherwise throw an error with invariant message - * @param {boolean} fact - * @param {string} msg - * @param {Array} rest - * @returns {void} + * @param fact + * @param msg + * @param rest */ -export function invariant(fact, msg, ...rest) { +export function invariant(fact: boolean, msg: string, ...rest: any[]) { if (!fact) { const error = new Error(`INVARIANT ${msg}`) error.stack = error.stack - .split("\n") - .filter(d => !/at invariant/.test(d)) - .join("\n") + ?.split("\n") + ?.filter(d => !/at invariant/.test(d)) + ?.join("\n") console.error("\n\n---\n\n", error, "\n\n", ...rest, "\n\n---\n\n") throw error } diff --git a/packages/util-invariant/tsconfig.json b/packages/util-invariant/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/util-invariant/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/util-logger/.babelrc b/packages/util-logger/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-logger/.babelrc +++ b/packages/util-logger/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-logger/.eslintrc.json b/packages/util-logger/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-logger/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-logger/CHANGELOG.md b/packages/util-logger/CHANGELOG.md index 7d532bf11..cb4ca33d4 100644 --- a/packages/util-logger/CHANGELOG.md +++ b/packages/util-logger/CHANGELOG.md @@ -1,5 +1,24 @@ # @onflow/util-logger +## 1.3.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript + +## 1.3.0-alpha.0 + +### Minor Changes + +- TS build + +### Patch Changes + +- Updated dependencies []: + - @onflow/config@1.2.0-alpha.0 + ## 1.2.2 ### Patch Changes diff --git a/packages/util-logger/package.json b/packages/util-logger/package.json index 7d5fe9a75..9a7f39734 100644 --- a/packages/util-logger/package.json +++ b/packages/util-logger/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-logger", - "version": "1.2.2", + "version": "1.3.0", "description": "Logger for FCL-JS", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/util-logger.js", + "source": "src/util-logger.ts", "main": "dist/util-logger.js", "module": "dist/util-logger.module.js", "unpkg": "dist/util-logger.umd.js", + "types": "dist/util-logger.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-logger/src/util-logger.js b/packages/util-logger/src/util-logger.js deleted file mode 100644 index 489cbd11f..000000000 --- a/packages/util-logger/src/util-logger.js +++ /dev/null @@ -1,151 +0,0 @@ -// Config dependency injected into logger to break circular dependency -let config = null -export const setConfig = _config => { - config = _config -} - -/** - * The levels of the logger - * - * @typedef {Object} LEVELS - * @property {number} debug - The debug level - * @property {number} info - The info level - * @property {number} log - The log level - * @property {number} warn - The warn level - * @property {number} error - The error level - * - */ -export const LEVELS = Object.freeze({ - debug: 5, - info: 4, - log: 3, - warn: 2, - error: 1, -}) - -/** - * Builds a message formatted for the logger - * - * @param {Object} options - The options for the log - * @param {string} options.title - The title of the log - * @param {string} options.message - The message of the log - * @returns {Array} - The message formatted for the logger - * - * @example - * buildLoggerMessageArgs({ title: "My Title", message: "My Message" }) - */ -const buildLoggerMessageArgs = ({title, message}) => { - return [ - ` - %c${title} - ============================ - - ${message} - - ============================ - ` - .replace(/\n[^\S\r\n]+/g, "\n") - .trim(), - , - "font-weight:bold;font-family:monospace;", - ] -} - -/** - * Logs messages based on the level of the message and the level set in the config - * - * @param {Object} options - The options for the log - * @param {string} options.title - The title of the log - * @param {string} options.message - The message of the log - * @param {number} options.level - The level of the log - * @param {boolean} options.always - Whether to always show the log - * @returns {Promise} - * - * @example - * log({ title: "My Title", message: "My Message", level: LEVELS.warn, always: false }) - * - */ -export const log = async ({title, message, level, always = false}) => { - const configLoggerLevel = - (await config?.()?.get("logger.level")) ?? LEVELS.warn - - // If config level is below message level then don't show it - if (!always && configLoggerLevel < level) return - - const loggerMessageArgs = buildLoggerMessageArgs({title, message}) - - switch (level) { - case LEVELS.debug: - console.debug(...loggerMessageArgs) - break - case LEVELS.info: - console.info(...loggerMessageArgs) - break - case LEVELS.warn: - console.warn(...loggerMessageArgs) - break - case LEVELS.error: - console.error(...loggerMessageArgs) - break - default: - console.log(...loggerMessageArgs) - } -} - -/** - * Logs a deprecation notice - * - * @param {Object} options - The options for the log - * @param {string} options.pkg - The package that is being deprecated - * @param {string} options.subject - The subject of the deprecation - * @param {string} options.transition - The transition path for the deprecation - * @param {number} options.level - The level of the log - * @param {string} options.message - The message of the log - * @param {Function} options.callback - A callback to run after the log - * @returns {Promise} - * - * @example - * log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/onflow/flow-js-sdk", message: "Descriptive message", level: LEVELS.warn, callback: () => {} }) - * - */ -log.deprecate = ({ - pkg, - subject, - transition, - level = LEVELS.warn, - message = "", - callback = null, -}) => { - const capitalizeFirstLetter = string => { - return string.charAt(0).toUpperCase() + string.slice(1) - } - - const logMessage = () => - log({ - title: `${pkg ? pkg + " " : ""}Deprecation Notice`, - message: ` - ${ - subject - ? `${capitalizeFirstLetter( - subject - )} is deprecated and will cease to work in future releases${ - pkg ? " of " + pkg : "" - }.` - : "" - }${message ? "\n" + message : ""}${ - transition - ? `\nYou can learn more (including a guide on common transition paths) here: ${transition}` - : "" - } - `.trim(), - level, - }) - - if (typeof callback === "function") { - return async (...args) => { - await logMessage() - return await callback(...args) - } - } - return logMessage() -} diff --git a/packages/util-logger/src/util-logger.test.js b/packages/util-logger/src/util-logger.test.ts similarity index 100% rename from packages/util-logger/src/util-logger.test.js rename to packages/util-logger/src/util-logger.test.ts diff --git a/packages/util-logger/src/util-logger.ts b/packages/util-logger/src/util-logger.ts new file mode 100644 index 000000000..9b3f4eb2b --- /dev/null +++ b/packages/util-logger/src/util-logger.ts @@ -0,0 +1,156 @@ +// Config dependency injected into logger to break circular dependency +let config: (() => {get: (key: string) => Promise}) | null = null +export const setConfig = (_config: typeof config) => { + config = _config +} + +/** + * The levels of the logger + */ +export enum LEVELS { + debug = 5, + info = 4, + log = 3, + warn = 2, + error = 1, +} + +/** + * Builds a message formatted for the logger + * @param options - The options for the log + * @param options.title - The title of the log + * @param options.message - The message of the log + * @returns The message formatted for the logger + * @example + * buildLoggerMessageArgs({ title: "My Title", message: "My Message" }) + */ +const buildLoggerMessageArgs = (options: { + title: string + message: string +}): string[] => { + const {title, message} = options + return [ + ` + %c${title} + ============================ + + ${message} + + ============================ + ` + .replace(/\n[^\S\r\n]+/g, "\n") + .trim(), + "font-weight:bold;font-family:monospace;", + ] +} + +/** + * Logs messages based on the level of the message and the level set in the config + * @param options - The options for the log + * @param options.title - The title of the log + * @param options.message - The message of the log + * @param options.level - The level of the log + * @param options.always - Whether to always show the log + * @example + * log({ title: "My Title", message: "My Message", level: LEVELS.warn, always: false }) + */ +export const log = async (options: { + title: string + message: string + level: number + always?: boolean +}) => { + const {title, message, level, always} = options + const configLoggerLevel = (await config?.()?.get("logger.level")) ?? LEVELS.warn + + // If config level is below message level then don't show it + if (!always && configLoggerLevel < level) return + + const loggerMessageArgs = buildLoggerMessageArgs({title, message}) + + switch (level) { + case LEVELS.debug: + console.debug(...loggerMessageArgs) + break + case LEVELS.info: + console.info(...loggerMessageArgs) + break + case LEVELS.warn: + console.warn(...loggerMessageArgs) + break + case LEVELS.error: + console.error(...loggerMessageArgs) + break + default: + console.log(...loggerMessageArgs) + } +} + +/** + * Logs a deprecation notice. If a callback is provided this function returns a function that will call the callback and log the deprecation notice, otherwise it just logs the deprecation notice. + * @param options - The options for the log + * @param options.pkg - The package that is being deprecated + * @param options.subject - The subject of the deprecation + * @param options.transition - The transition path for the deprecation + * @param options.level - The level of the log + * @param options.message - The message of the log + * @param options.callback - A callback to run after the log + * @returns A function that will call the callback and log the deprecation notice if the callback is provided + * @example + * // Logs a deprecation notice + * log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/onflow/flow-js-sdk", message: "Descriptive message", level: LEVELS.warn, callback: () => {} }) + * @example + * function someFunction() { ... } + * const deprecatedFunction = log.deprecate({ pkg: "@onflow/fcl", subject: "Some item", transition: "https://github.com/foo/bar/TRANSITIONS.md", message: "Descriptive message", level: LEVELS.warn, callback: someFunction }) + * deprecatedFunction() // Calls someFunction and logs the deprecation notice + */ +log.deprecate = (options: { + pkg?: string + subject?: string + transition?: string + level?: number + message?: string + callback?: (...args: T[]) => U +}): ((...args: T[]) => Promise) | Promise => { + const { + pkg, + subject, + transition, + level = LEVELS.warn, + message = "", + callback = null, + } = options + + const capitalizeFirstLetter = (str: string) => { + return str.charAt(0).toUpperCase() + str.slice(1) + } + + const logMessage = () => + log({ + title: `${pkg ? pkg + " " : ""}Deprecation Notice`, + message: ` + ${ + subject + ? `${capitalizeFirstLetter( + subject + )} is deprecated and will cease to work in future releases${ + pkg ? " of " + pkg : "" + }.` + : "" + }${message ? "\n" + message : ""}${ + transition + ? `\nYou can learn more (including a guide on common transition paths) here: ${transition}` + : "" + } + `.trim(), + level, + }) + + if (typeof callback === "function") { + return async (...args: T[]) => { + await logMessage() + return await callback(...args) + } + } + return logMessage() +} diff --git a/packages/util-logger/tsconfig.json b/packages/util-logger/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/util-logger/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/packages/util-template/.babelrc b/packages/util-template/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-template/.babelrc +++ b/packages/util-template/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-template/.eslintrc.json b/packages/util-template/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-template/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-template/CHANGELOG.md b/packages/util-template/CHANGELOG.md index 1d6b910bd..46422f24d 100644 --- a/packages/util-template/CHANGELOG.md +++ b/packages/util-template/CHANGELOG.md @@ -1,5 +1,24 @@ # @onflow/util-template +## 1.2.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript + +### Patch Changes + +- Updated dependencies [[`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea), [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477)]: + - @onflow/util-logger@1.3.0 + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/util-template/package.json b/packages/util-template/package.json index 87a72afe9..8040a7716 100644 --- a/packages/util-template/package.json +++ b/packages/util-template/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-template", - "version": "1.1.0", + "version": "1.2.0", "description": "Template Literal used for Cadence Interop", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/template.js", + "source": "src/template.ts", "main": "dist/template.js", "module": "dist/template.module.js", "unpkg": "dist/template.umd.js", + "types": "dist/template.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", @@ -28,6 +35,7 @@ "start": "fcl-bundle --watch" }, "dependencies": { - "@babel/runtime": "^7.18.6" + "@babel/runtime": "^7.18.6", + "@onflow/util-logger": "^1.3.0" } } diff --git a/packages/util-template/src/__snapshots__/template.test.js.snap b/packages/util-template/src/__snapshots__/template.test.ts.snap similarity index 94% rename from packages/util-template/src/__snapshots__/template.test.js.snap rename to packages/util-template/src/__snapshots__/template.test.ts.snap index 5a768939f..614f991a9 100644 --- a/packages/util-template/src/__snapshots__/template.test.js.snap +++ b/packages/util-template/src/__snapshots__/template.test.ts.snap @@ -10,7 +10,7 @@ exports[`template interop function template(template\`\${o=>o.a}\`)(o) -> 'abc' exports[`template interop function template\`\${o=>o.a}\`(o) -> 'abc' 1`] = `"abc"`; -exports[`template interop more template template(template\`x\${template\`y\${o => o.a}\`}\`)(o) -> 'xyabc' 1`] = `"xyabc"`; +exports[`template interop more template template(template\`x\${template\`y\${(_o: typeof o) => _o.a}\`}\`)(o) -> 'xyabc' 1`] = `"xyabc"`; exports[`template interop more template template\`x\${template\`y\${o=>o.a}\`}\`(o) => 'xyabc' 1`] = `"xyabc"`; diff --git a/packages/util-template/src/template.js b/packages/util-template/src/template.js deleted file mode 100644 index e064dab37..000000000 --- a/packages/util-template/src/template.js +++ /dev/null @@ -1,46 +0,0 @@ -import {log} from "@onflow/util-logger" - -export function interleave(a = [], b = [], c = []) { - if (!a.length && !b.length) return c - if (!a.length) return c - if (!b.length) return [...c, a[0]] - - const [aHead, ...aRest] = a - const [bHead, ...bRest] = b - - if (aHead !== undefined) c.push(aHead) - if (bHead !== undefined) c.push(bHead) - - return interleave(aRest, bRest, c) -} - -function recApply(d) { - return function (arg1) { - if (typeof arg1 === "function") { - log.deprecate({ - pkg: "FCL/SDK", - subject: "Interopolation of functions into template literals", - transition: - "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", - }) - return recApply(d)(arg1(d)) - } - return String(arg1) - } -} - -/** - * @param {(string|Array.<*>)} head - * @param {Array.<*>} rest - * @returns {{function(): string}} - */ -export function template(head, ...rest) { - if (typeof head === "string") return () => head - if (Array.isArray(head)) { - return d => - interleave(head, rest.map(recApply(d))) - .join("") - .trim() - } - return head -} diff --git a/packages/util-template/src/template.test.js b/packages/util-template/src/template.test.ts similarity index 72% rename from packages/util-template/src/template.test.js rename to packages/util-template/src/template.test.ts index 6014f676c..dac1be6cb 100644 --- a/packages/util-template/src/template.test.js +++ b/packages/util-template/src/template.test.ts @@ -23,14 +23,14 @@ describe("interleave", () => { }) }) -const _ = (msg, a, b) => { +const _ = (msg: string, a: unknown, b?: unknown) => { if (b == null) { test(msg, () => expect(a).toMatchSnapshot()) } else { test(msg, () => expect(a).toBe(b)) } } -const t = v => typeof v +const t = (v: T) => typeof v describe("template", () => { describe("input type vs output type", () => { @@ -52,10 +52,10 @@ describe("template", () => { describe("interop function", () => { const o = {a: "abc"} - _("template`${o=>o.a}`(o) -> 'abc'", template`${o => o.a}`(o)) + _("template`${o=>o.a}`(o) -> 'abc'", template`${(_o: typeof o) => _o.a}`(o)) _( "template(template`${o=>o.a}`)(o) -> 'abc'", - template(template`${o => o.a}`)(o) + template(template`${(_o: typeof o) => _o.a}`)(o) ) }) @@ -63,20 +63,20 @@ describe("template", () => { const o = {a: "abc"} _( "template`x${template`y${o=>o.a}`}`(o) => 'xyabc'", - template`x${template`y${o => o.a}`}`(o) + template`x${template`y${(_o: typeof o) => _o.a}`}`(o) ) _( "template`x${template`y${template`z${o=>o.a}`}`}`(o) => 'xyabc'", - template`x${template`y${template`z${o => o.a}`}`}`(o) + template`x${template`y${template`z${(_o: typeof o) => _o.a}`}`}`(o) ) _( - "template(template`x${template`y${o => o.a}`}`)(o) -> 'xyabc'", - template(template`x${template`y${o => o.a}`}`)(o) + "template(template`x${template`y${(_o: typeof o) => _o.a}`}`)(o) -> 'xyabc'", + template(template`x${template`y${(_o: typeof o) => _o.a}`}`)(o) ) }) describe("interop nested functions", () => { - const fn = a => b => c => d => e => f => f.a + const fn = () => () => () => () => () => (f: typeof o) => f.a const o = {a: "abc"} _("template`${fn}`(o) -> 'abc'", template`${fn}`(o)) }) @@ -88,8 +88,10 @@ describe("template", () => { describe("object can have non string values", () => { const data = {a: 1, b: NaN, c: undefined, d: null, e: false, f: true} - const tx = template`a:${o => o.a}|b:${o => o.b}|c:${o => o.c}|d:${o => - o.d}|e:${o => o.e}|f:${o => o.f}` + const tx = template`a:${(o: typeof data) => o.a}|b:${(o: typeof data) => + o.b}|c:${(o: typeof data) => o.c}|d:${(o: typeof data) => o.d}|e:${( + o: typeof data + ) => o.e}|f:${(o: typeof data) => o.f}` _("template(data)", tx(data), "a:1|b:NaN|c:undefined|d:null|e:false|f:true") }) }) diff --git a/packages/util-template/src/template.ts b/packages/util-template/src/template.ts new file mode 100644 index 000000000..e2a68ae2e --- /dev/null +++ b/packages/util-template/src/template.ts @@ -0,0 +1,67 @@ +import {log} from "@onflow/util-logger" + +/** + * Interleaves two arrays + * @param a - The first array + * @param b - The second array + * @param c - The target array + * @returns The interleaved array + */ +export function interleave( + a: A[] = [], + b: B[] = [], + c: (A | B)[] = [] +): (A | B)[] { + if (!a.length && !b.length) return c + if (!a.length) return c + if (!b.length) { + c.push(...a) + return c + } + + const [aHead, ...aRest] = a + const [bHead, ...bRest] = b + + if (aHead !== undefined) c.push(aHead) + if (bHead !== undefined) c.push(bHead) + + return interleave(aRest, bRest, c) +} + +/** + * Recursively apply a value to a function + * @param d - The value to apply + * @returns A function that takes a function and applies the value to it + */ +function recApply(d: T): (x: U) => string { + return function (arg1) { + if (typeof arg1 === "function") { + log.deprecate({ + pkg: "FCL/SDK", + subject: "Interopolation of functions into template literals", + transition: + "https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params", + }) + return recApply(d)(arg1(d)) + } + return String(arg1) + } +} + +/** + * Creates a template function + * @param head - A string, template string array, or template function + * @param rest - The rest of the arguments + * @returns A template function + */ +export function template( + head: string | TemplateStringsArray | ((x?: unknown) => string), + ...rest: unknown[] +): (x?: unknown) => string { + if (typeof head === "string") return () => head + if (typeof head === "function") return head + return (x: unknown) => + interleave([...head], rest.map(recApply(x))) + .join("") + .trim() +} diff --git a/packages/util-template/tsconfig.json b/packages/util-template/tsconfig.json new file mode 100644 index 000000000..4ec7af1fd --- /dev/null +++ b/packages/util-template/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types" + }, + "exclude": ["src/__snapshots__"] +} diff --git a/packages/util-uid/.babelrc b/packages/util-uid/.babelrc index 67fc2886b..d766c90b2 100644 --- a/packages/util-uid/.babelrc +++ b/packages/util-uid/.babelrc @@ -1,7 +1,3 @@ { - "presets": [ - [ - "@babel/preset-env" - ] - ] + "presets": [["@babel/preset-env"], "@babel/preset-typescript"] } diff --git a/packages/util-uid/.eslintrc.json b/packages/util-uid/.eslintrc.json new file mode 100644 index 000000000..e80c057f5 --- /dev/null +++ b/packages/util-uid/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "es2021": true, + "jest": true, + "node": true + }, + "extends": [ + "plugin:jsdoc/recommended-typescript", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsdoc", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns": ["**/dist/"] +} diff --git a/packages/util-uid/CHANGELOG.md b/packages/util-uid/CHANGELOG.md index 841eb6100..b02276ea2 100644 --- a/packages/util-uid/CHANGELOG.md +++ b/packages/util-uid/CHANGELOG.md @@ -1,5 +1,19 @@ # @onflow/util-uid +## 1.2.0 + +### Minor Changes + +- [#1728](https://github.com/onflow/fcl-js/pull/1728) [`a4f8c00c`](https://github.com/onflow/fcl-js/commit/a4f8c00c4cf292d3a4afac610dedbc89ff3affea) Thanks [@nialexsan](https://github.com/nialexsan)! - TS build + +- [#1750](https://github.com/onflow/fcl-js/pull/1750) [`845ffa75`](https://github.com/onflow/fcl-js/commit/845ffa756e07188557d150cdb9ff7af59019a477) Thanks [@jribbink](https://github.com/jribbink)! - Convert to Typescript + +## 1.2.0-alpha.0 + +### Minor Changes + +- TS build + ## 1.1.0 ### Minor Changes diff --git a/packages/util-uid/package.json b/packages/util-uid/package.json index bd6fb3856..d93bf74cc 100644 --- a/packages/util-uid/package.json +++ b/packages/util-uid/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/util-uid", - "version": "1.1.0", + "version": "1.2.0", "description": "Utilities to generate Unique Identifiers", "license": "Apache-2.0", "author": "Dapper Labs ", @@ -13,13 +13,20 @@ "url": "https://github.com/onflow/flow-js-sdk/issues" }, "devDependencies": { - "@onflow/fcl-bundle": "^1.3.1-alpha.0", + "@babel/preset-typescript": "^7.22.5", + "@onflow/fcl-bundle": "^1.4.0", + "@types/jest": "^29.5.3", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", + "eslint": "^8.47.0", + "eslint-plugin-jsdoc": "^46.4.6", "jest": "^29.5.0" }, - "source": "src/util-uid.js", + "source": "src/util-uid.ts", "main": "dist/util-uid.js", "module": "dist/util-uid.module.js", "unpkg": "dist/util-uid.umd.js", + "types": "dist/util-uid.d.ts", "scripts": { "prepublishOnly": "npm test && npm run build", "test": "jest", diff --git a/packages/util-uid/src/util-uid.js b/packages/util-uid/src/util-uid.js deleted file mode 100644 index 878d61dd8..000000000 --- a/packages/util-uid/src/util-uid.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generates a unique identifier - * @returns {string} - */ -var HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" -var T = HEX.length - -export function uid() { - var str = "", - num = 32 - while (num--) str += HEX[(Math.random() * T) | 0] - return str -} diff --git a/packages/util-uid/src/util-uid.test.js b/packages/util-uid/src/util-uid.test.js deleted file mode 100644 index 0fbcb9ae6..000000000 --- a/packages/util-uid/src/util-uid.test.js +++ /dev/null @@ -1,5 +0,0 @@ -import {uid} from "./util-uid.js" - -test("placeholder", () => { - expect(uid()).not.toBe(1) -}) diff --git a/packages/util-uid/src/util-uid.test.ts b/packages/util-uid/src/util-uid.test.ts new file mode 100644 index 000000000..637cbe4f6 --- /dev/null +++ b/packages/util-uid/src/util-uid.test.ts @@ -0,0 +1,12 @@ +import {uid} from "./util-uid" + +test("it should generate a unique 32 character alphanumeric string", () => { + const set = new Set() + for (let i = 0; i < 1000; i++) { + const id = uid() + expect(id).toMatch(/^[a-zA-Z0-9]{32}$/) + expect(set.has(id)).toBe(false) + set.add(id) + } + expect(set.size).toBe(1000) +}) diff --git a/packages/util-uid/src/util-uid.ts b/packages/util-uid/src/util-uid.ts new file mode 100644 index 000000000..651251ef7 --- /dev/null +++ b/packages/util-uid/src/util-uid.ts @@ -0,0 +1,13 @@ +const HEX = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" +const T = HEX.length + +/** + * Generates a random unique identifier + * @returns 32 character alphanumeric string + */ +export function uid(): string { + let str = "", + num = 32 + while (num--) str += HEX[(Math.random() * T) | 0] + return str +} diff --git a/packages/util-uid/tsconfig.json b/packages/util-uid/tsconfig.json new file mode 100644 index 000000000..88be905eb --- /dev/null +++ b/packages/util-uid/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig", + // Change this to match your project + "include": ["src/**/*"], + "compilerOptions": { + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "types", + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..244c48d2e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + // Change this to match your project + "exclude": ["**/*.test.ts", "**/*.test.js"], + "compilerOptions": { + "moduleResolution": "NodeNext", + "target": "ES2015", + "types": ["node", "jest"], + // Tells TypeScript to read JS files, as + // normally they are ignored as source files + "allowJs": true, + // Generate d.ts files + "declaration": true, + // This compiler run should + // only output d.ts files + "emitDeclarationOnly": true, + // go to js file when using IDE functions like + // "Go to Definition" in VSCode + "declarationMap": false, + "strict": true + } +}