From 234a01ac4479803d16b8fe6837080dc1a5fa9135 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 09:53:45 +0200 Subject: [PATCH 01/53] chore(shared): Smaller package.json maintenance --- package-lock.json | 201 ++++++++++++++++++++++++++++------- packages/shared/package.json | 22 ++-- 2 files changed, 177 insertions(+), 46 deletions(-) diff --git a/package-lock.json b/package-lock.json index a3657e04df..3bb9daec3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,6 +63,7 @@ }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -75,7 +76,7 @@ }, "node_modules/@ampproject/remapping": { "version": "2.2.1", - "devOptional": true, + "dev": true, "license": "Apache-2.0", "dependencies": { "@jridgewell/gen-mapping": "^0.3.0", @@ -293,7 +294,7 @@ }, "node_modules/@babel/compat-data": { "version": "7.22.9", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -301,7 +302,7 @@ }, "node_modules/@babel/core": { "version": "7.22.1", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", @@ -330,7 +331,7 @@ }, "node_modules/@babel/core/node_modules/semver": { "version": "6.3.0", - "devOptional": true, + "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -371,7 +372,7 @@ }, "node_modules/@babel/generator": { "version": "7.22.3", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.22.3", @@ -407,7 +408,7 @@ }, "node_modules/@babel/helper-compilation-targets": { "version": "7.22.15", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/compat-data": "^7.22.9", @@ -422,7 +423,7 @@ }, "node_modules/@babel/helper-compilation-targets/node_modules/semver": { "version": "6.3.1", - "devOptional": true, + "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -499,7 +500,7 @@ }, "node_modules/@babel/helper-environment-visitor": { "version": "7.22.1", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -507,7 +508,7 @@ }, "node_modules/@babel/helper-function-name": { "version": "7.21.0", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.20.7", @@ -519,7 +520,7 @@ }, "node_modules/@babel/helper-hoist-variables": { "version": "7.18.6", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.18.6" @@ -551,7 +552,7 @@ }, "node_modules/@babel/helper-module-transforms": { "version": "7.22.1", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/helper-environment-visitor": "^7.22.1", @@ -621,7 +622,7 @@ }, "node_modules/@babel/helper-simple-access": { "version": "7.21.5", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.21.5" @@ -643,7 +644,7 @@ }, "node_modules/@babel/helper-split-export-declaration": { "version": "7.18.6", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.18.6" @@ -668,7 +669,7 @@ }, "node_modules/@babel/helper-validator-option": { "version": "7.22.15", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -690,7 +691,7 @@ }, "node_modules/@babel/helpers": { "version": "7.22.3", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.21.9", @@ -715,7 +716,7 @@ }, "node_modules/@babel/parser": { "version": "7.22.4", - "devOptional": true, + "dev": true, "license": "MIT", "bin": { "parser": "bin/babel-parser.js" @@ -2163,7 +2164,7 @@ }, "node_modules/@babel/template": { "version": "7.21.9", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.21.4", @@ -2176,7 +2177,7 @@ }, "node_modules/@babel/traverse": { "version": "7.22.4", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.21.4", @@ -3810,6 +3811,7 @@ }, "node_modules/@eslint/eslintrc": { "version": "2.1.2", + "dev": true, "license": "MIT", "dependencies": { "ajv": "^6.12.4", @@ -3831,10 +3833,12 @@ }, "node_modules/@eslint/eslintrc/node_modules/argparse": { "version": "2.0.1", + "dev": true, "license": "Python-2.0" }, "node_modules/@eslint/eslintrc/node_modules/globals": { "version": "13.21.0", + "dev": true, "license": "MIT", "dependencies": { "type-fest": "^0.20.2" @@ -3848,6 +3852,7 @@ }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", + "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -3858,6 +3863,7 @@ }, "node_modules/@eslint/js": { "version": "8.49.0", + "dev": true, "license": "MIT", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -4114,6 +4120,7 @@ }, "node_modules/@fastify/ajv-compiler": { "version": "3.5.0", + "dev": true, "license": "MIT", "dependencies": { "ajv": "^8.11.0", @@ -4123,6 +4130,7 @@ }, "node_modules/@fastify/ajv-compiler/node_modules/ajv": { "version": "8.12.0", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -4137,18 +4145,22 @@ }, "node_modules/@fastify/ajv-compiler/node_modules/json-schema-traverse": { "version": "1.0.0", + "dev": true, "license": "MIT" }, "node_modules/@fastify/deepmerge": { "version": "1.3.0", + "dev": true, "license": "MIT" }, "node_modules/@fastify/error": { "version": "3.2.1", + "dev": true, "license": "MIT" }, "node_modules/@fastify/fast-json-stringify-compiler": { "version": "4.3.0", + "dev": true, "license": "MIT", "dependencies": { "fast-json-stringify": "^5.7.0" @@ -4747,6 +4759,7 @@ }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.11", + "dev": true, "license": "Apache-2.0", "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", @@ -4759,6 +4772,7 @@ }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=12.22" @@ -4770,6 +4784,7 @@ }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/@iarna/toml": { @@ -5616,7 +5631,7 @@ }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/set-array": "^1.0.1", @@ -5629,7 +5644,7 @@ }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.0", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=6.0.0" @@ -5637,7 +5652,7 @@ }, "node_modules/@jridgewell/set-array": { "version": "1.1.2", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=6.0.0" @@ -5654,12 +5669,12 @@ }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.18", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "3.1.0", @@ -5668,7 +5683,7 @@ }, "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.14", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/@leichtgewicht/ip-codec": { @@ -8998,6 +9013,7 @@ }, "node_modules/abort-controller": { "version": "3.0.0", + "dev": true, "license": "MIT", "dependencies": { "event-target-shim": "^5.0.0" @@ -9013,6 +9029,7 @@ }, "node_modules/abstract-logging": { "version": "2.0.1", + "dev": true, "license": "MIT" }, "node_modules/accepts": { @@ -9029,6 +9046,7 @@ }, "node_modules/acorn": { "version": "8.10.0", + "dev": true, "license": "MIT", "bin": { "acorn": "bin/acorn" @@ -9056,6 +9074,7 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", + "dev": true, "license": "MIT", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" @@ -9101,6 +9120,7 @@ }, "node_modules/ajv": { "version": "6.12.6", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -9115,6 +9135,7 @@ }, "node_modules/ajv-formats": { "version": "2.1.1", + "dev": true, "license": "MIT", "dependencies": { "ajv": "^8.0.0" @@ -9130,6 +9151,7 @@ }, "node_modules/ajv-formats/node_modules/ajv": { "version": "8.12.0", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -9144,6 +9166,7 @@ }, "node_modules/ajv-formats/node_modules/json-schema-traverse": { "version": "1.0.0", + "dev": true, "license": "MIT" }, "node_modules/ajv-keywords": { @@ -9213,6 +9236,7 @@ }, "node_modules/ansi-regex": { "version": "5.0.1", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -9276,6 +9300,7 @@ }, "node_modules/archy": { "version": "1.0.0", + "dev": true, "license": "MIT" }, "node_modules/arg": { @@ -9505,6 +9530,7 @@ }, "node_modules/atomic-sleep": { "version": "1.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=8.0.0" @@ -9569,6 +9595,7 @@ }, "node_modules/avvio": { "version": "8.2.1", + "dev": true, "license": "MIT", "dependencies": { "archy": "^1.0.0", @@ -10350,7 +10377,7 @@ }, "node_modules/browserslist": { "version": "4.21.10", - "devOptional": true, + "dev": true, "funding": [ { "type": "opencollective", @@ -10693,7 +10720,7 @@ }, "node_modules/caniuse-lite": { "version": "1.0.30001528", - "devOptional": true, + "dev": true, "funding": [ { "type": "opencollective", @@ -11743,6 +11770,7 @@ }, "node_modules/cross-spawn": { "version": "7.0.3", + "dev": true, "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -12255,6 +12283,7 @@ }, "node_modules/deep-is": { "version": "0.1.4", + "dev": true, "license": "MIT" }, "node_modules/deepmerge": { @@ -12561,6 +12590,7 @@ }, "node_modules/doctrine": { "version": "3.0.0", + "dev": true, "license": "Apache-2.0", "dependencies": { "esutils": "^2.0.2" @@ -12727,7 +12757,7 @@ }, "node_modules/electron-to-chromium": { "version": "1.4.510", - "devOptional": true, + "dev": true, "license": "ISC" }, "node_modules/emittery": { @@ -13506,7 +13536,7 @@ }, "node_modules/escalade": { "version": "3.1.1", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -13605,6 +13635,7 @@ }, "node_modules/eslint": { "version": "8.49.0", + "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", @@ -13959,6 +13990,7 @@ }, "node_modules/eslint-scope": { "version": "7.2.2", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", @@ -14064,6 +14096,7 @@ }, "node_modules/eslint/node_modules/ansi-styles": { "version": "4.3.0", + "dev": true, "license": "MIT", "dependencies": { "color-convert": "^2.0.1" @@ -14077,10 +14110,12 @@ }, "node_modules/eslint/node_modules/argparse": { "version": "2.0.1", + "dev": true, "license": "Python-2.0" }, "node_modules/eslint/node_modules/chalk": { "version": "4.1.2", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", @@ -14095,6 +14130,7 @@ }, "node_modules/eslint/node_modules/color-convert": { "version": "2.0.1", + "dev": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -14105,10 +14141,12 @@ }, "node_modules/eslint/node_modules/color-name": { "version": "1.1.4", + "dev": true, "license": "MIT" }, "node_modules/eslint/node_modules/globals": { "version": "13.20.0", + "dev": true, "license": "MIT", "dependencies": { "type-fest": "^0.20.2" @@ -14122,6 +14160,7 @@ }, "node_modules/eslint/node_modules/has-flag": { "version": "4.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -14129,6 +14168,7 @@ }, "node_modules/eslint/node_modules/js-yaml": { "version": "4.1.0", + "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -14139,6 +14179,7 @@ }, "node_modules/eslint/node_modules/supports-color": { "version": "7.2.0", + "dev": true, "license": "MIT", "dependencies": { "has-flag": "^4.0.0" @@ -14149,6 +14190,7 @@ }, "node_modules/espree": { "version": "9.6.1", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "acorn": "^8.9.0", @@ -14176,6 +14218,7 @@ }, "node_modules/esquery": { "version": "1.5.0", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "estraverse": "^5.1.0" @@ -14257,6 +14300,7 @@ }, "node_modules/event-target-shim": { "version": "5.0.1", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -14269,6 +14313,7 @@ }, "node_modules/events": { "version": "3.3.0", + "dev": true, "license": "MIT", "engines": { "node": ">=0.8.x" @@ -14694,14 +14739,17 @@ }, "node_modules/fast-content-type-parse": { "version": "1.0.0", + "dev": true, "license": "MIT" }, "node_modules/fast-decode-uri-component": { "version": "1.0.1", + "dev": true, "license": "MIT" }, "node_modules/fast-deep-equal": { "version": "3.1.3", + "dev": true, "license": "MIT" }, "node_modules/fast-fifo": { @@ -14736,10 +14784,12 @@ }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", + "dev": true, "license": "MIT" }, "node_modules/fast-json-stringify": { "version": "5.7.0", + "dev": true, "license": "MIT", "dependencies": { "@fastify/deepmerge": "^1.0.0", @@ -14752,6 +14802,7 @@ }, "node_modules/fast-json-stringify/node_modules/ajv": { "version": "8.12.0", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -14766,14 +14817,17 @@ }, "node_modules/fast-json-stringify/node_modules/json-schema-traverse": { "version": "1.0.0", + "dev": true, "license": "MIT" }, "node_modules/fast-levenshtein": { "version": "2.0.6", + "dev": true, "license": "MIT" }, "node_modules/fast-querystring": { "version": "1.1.2", + "dev": true, "license": "MIT", "dependencies": { "fast-decode-uri-component": "^1.0.1" @@ -14781,6 +14835,7 @@ }, "node_modules/fast-redact": { "version": "3.2.0", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -14788,6 +14843,7 @@ }, "node_modules/fast-uri": { "version": "2.2.0", + "dev": true, "license": "MIT" }, "node_modules/fastest-levenshtein": { @@ -14799,6 +14855,7 @@ }, "node_modules/fastify": { "version": "4.12.0", + "dev": true, "license": "MIT", "dependencies": { "@fastify/ajv-compiler": "^3.3.1", @@ -14820,6 +14877,7 @@ }, "node_modules/fastify-plugin": { "version": "4.5.0", + "dev": true, "license": "MIT" }, "node_modules/fastq": { @@ -14913,6 +14971,7 @@ }, "node_modules/file-entry-cache": { "version": "6.0.1", + "dev": true, "license": "MIT", "dependencies": { "flat-cache": "^3.0.4" @@ -15012,6 +15071,7 @@ }, "node_modules/find-my-way": { "version": "7.6.2", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", @@ -15028,6 +15088,7 @@ }, "node_modules/find-up": { "version": "5.0.0", + "dev": true, "license": "MIT", "dependencies": { "locate-path": "^6.0.0", @@ -15051,6 +15112,7 @@ }, "node_modules/flat-cache": { "version": "3.0.4", + "dev": true, "license": "MIT", "dependencies": { "flatted": "^3.1.0", @@ -15062,6 +15124,7 @@ }, "node_modules/flat-cache/node_modules/glob": { "version": "7.2.3", + "dev": true, "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", @@ -15080,6 +15143,7 @@ }, "node_modules/flat-cache/node_modules/rimraf": { "version": "3.0.2", + "dev": true, "license": "ISC", "dependencies": { "glob": "^7.1.3" @@ -15093,6 +15157,7 @@ }, "node_modules/flatted": { "version": "3.2.7", + "dev": true, "license": "ISC" }, "node_modules/follow-redirects": { @@ -15364,6 +15429,7 @@ }, "node_modules/forwarded": { "version": "0.2.0", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -15443,6 +15509,7 @@ }, "node_modules/fs.realpath": { "version": "1.0.0", + "dev": true, "license": "ISC" }, "node_modules/fsevents": { @@ -16602,7 +16669,7 @@ }, "node_modules/gensync": { "version": "1.0.0-beta.2", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -16833,6 +16900,7 @@ }, "node_modules/glob-parent": { "version": "6.0.2", + "dev": true, "license": "ISC", "dependencies": { "is-glob": "^4.0.3" @@ -16913,7 +16981,7 @@ }, "node_modules/globals": { "version": "11.12.0", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -17017,6 +17085,7 @@ }, "node_modules/graphemer": { "version": "1.4.0", + "dev": true, "license": "MIT" }, "node_modules/graphql": { @@ -17583,6 +17652,7 @@ }, "node_modules/imurmurhash": { "version": "0.1.4", + "dev": true, "license": "MIT", "engines": { "node": ">=0.8.19" @@ -17598,6 +17668,7 @@ }, "node_modules/inflight": { "version": "1.0.6", + "dev": true, "license": "ISC", "dependencies": { "once": "^1.3.0", @@ -17606,6 +17677,7 @@ }, "node_modules/inherits": { "version": "2.0.4", + "dev": true, "license": "ISC" }, "node_modules/ini": { @@ -17751,6 +17823,7 @@ }, "node_modules/ipaddr.js": { "version": "1.9.1", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.10" @@ -18058,6 +18131,7 @@ }, "node_modules/is-path-inside": { "version": "3.0.3", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -18335,6 +18409,7 @@ }, "node_modules/isexe": { "version": "2.0.0", + "dev": true, "license": "ISC" }, "node_modules/isobject": { @@ -20285,7 +20360,7 @@ }, "node_modules/jsesc": { "version": "2.5.2", - "devOptional": true, + "dev": true, "license": "MIT", "bin": { "jsesc": "bin/jsesc" @@ -20315,10 +20390,12 @@ }, "node_modules/json-schema-traverse": { "version": "0.4.1", + "dev": true, "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", + "dev": true, "license": "MIT" }, "node_modules/json-stringify-safe": { @@ -20328,7 +20405,7 @@ }, "node_modules/json5": { "version": "2.2.3", - "devOptional": true, + "dev": true, "license": "MIT", "bin": { "json5": "lib/cli.js" @@ -20487,6 +20564,7 @@ }, "node_modules/levn": { "version": "0.4.1", + "dev": true, "license": "MIT", "dependencies": { "prelude-ls": "^1.2.1", @@ -20498,6 +20576,7 @@ }, "node_modules/light-my-request": { "version": "5.9.2", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "cookie": "^0.5.0", @@ -20879,6 +20958,7 @@ }, "node_modules/locate-path": { "version": "6.0.0", + "dev": true, "license": "MIT", "dependencies": { "p-locate": "^5.0.0" @@ -20975,6 +21055,7 @@ }, "node_modules/lodash.merge": { "version": "4.6.2", + "dev": true, "license": "MIT" }, "node_modules/lodash.mergewith": { @@ -21215,7 +21296,7 @@ }, "node_modules/lru-cache": { "version": "5.1.1", - "devOptional": true, + "dev": true, "license": "ISC", "dependencies": { "yallist": "^3.0.2" @@ -21823,6 +21904,7 @@ }, "node_modules/natural-compare": { "version": "1.4.0", + "dev": true, "license": "MIT" }, "node_modules/natural-compare-lite": { @@ -22102,7 +22184,7 @@ }, "node_modules/node-releases": { "version": "2.0.13", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/node-watch": { @@ -22549,6 +22631,7 @@ }, "node_modules/on-exit-leak-free": { "version": "2.1.0", + "dev": true, "license": "MIT" }, "node_modules/on-finished": { @@ -22572,6 +22655,7 @@ }, "node_modules/once": { "version": "1.4.0", + "dev": true, "license": "ISC", "dependencies": { "wrappy": "1" @@ -22625,6 +22709,7 @@ }, "node_modules/optionator": { "version": "0.9.3", + "dev": true, "license": "MIT", "dependencies": { "@aashutoshrathi/word-wrap": "^1.2.3", @@ -22709,6 +22794,7 @@ }, "node_modules/p-locate": { "version": "5.0.0", + "dev": true, "license": "MIT", "dependencies": { "p-limit": "^3.0.2" @@ -22722,6 +22808,7 @@ }, "node_modules/p-locate/node_modules/p-limit": { "version": "3.1.0", + "dev": true, "license": "MIT", "dependencies": { "yocto-queue": "^0.1.0" @@ -23061,6 +23148,7 @@ }, "node_modules/path-exists": { "version": "4.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -23068,6 +23156,7 @@ }, "node_modules/path-is-absolute": { "version": "1.0.1", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -23075,6 +23164,7 @@ }, "node_modules/path-key": { "version": "3.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -23177,7 +23267,7 @@ }, "node_modules/picocolors": { "version": "1.0.0", - "devOptional": true, + "dev": true, "license": "ISC" }, "node_modules/picomatch": { @@ -23211,6 +23301,7 @@ }, "node_modules/pino": { "version": "8.14.1", + "dev": true, "license": "MIT", "dependencies": { "atomic-sleep": "^1.0.0", @@ -23231,6 +23322,7 @@ }, "node_modules/pino-abstract-transport": { "version": "1.0.0", + "dev": true, "license": "MIT", "dependencies": { "readable-stream": "^4.0.0", @@ -23239,6 +23331,7 @@ }, "node_modules/pino-abstract-transport/node_modules/buffer": { "version": "6.0.3", + "dev": true, "funding": [ { "type": "github", @@ -23261,6 +23354,7 @@ }, "node_modules/pino-abstract-transport/node_modules/readable-stream": { "version": "4.4.0", + "dev": true, "license": "MIT", "dependencies": { "abort-controller": "^3.0.0", @@ -23274,6 +23368,7 @@ }, "node_modules/pino-abstract-transport/node_modules/split2": { "version": "4.2.0", + "dev": true, "license": "ISC", "engines": { "node": ">= 10.x" @@ -23281,6 +23376,7 @@ }, "node_modules/pino-std-serializers": { "version": "6.2.1", + "dev": true, "license": "MIT" }, "node_modules/pirates": { @@ -24085,6 +24181,7 @@ }, "node_modules/prelude-ls": { "version": "1.2.1", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8.0" @@ -24177,6 +24274,7 @@ }, "node_modules/process": { "version": "0.11.10", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6.0" @@ -24189,6 +24287,7 @@ }, "node_modules/process-warning": { "version": "2.2.0", + "dev": true, "license": "MIT" }, "node_modules/progress": { @@ -24271,6 +24370,7 @@ }, "node_modules/proxy-addr": { "version": "2.0.7", + "dev": true, "license": "MIT", "dependencies": { "forwarded": "0.2.0", @@ -24425,6 +24525,7 @@ }, "node_modules/quick-format-unescaped": { "version": "4.0.4", + "dev": true, "license": "MIT" }, "node_modules/quick-lru": { @@ -24531,6 +24632,7 @@ }, "node_modules/react": { "version": "18.2.0", + "dev": true, "license": "MIT", "dependencies": { "loose-envify": "^1.1.0" @@ -24666,6 +24768,7 @@ }, "node_modules/react-dom": { "version": "18.2.0", + "dev": true, "license": "MIT", "dependencies": { "loose-envify": "^1.1.0", @@ -24982,6 +25085,7 @@ }, "node_modules/real-require": { "version": "0.2.0", + "dev": true, "license": "MIT", "engines": { "node": ">= 12.13.0" @@ -25224,6 +25328,7 @@ }, "node_modules/require-from-string": { "version": "2.0.2", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -25338,6 +25443,7 @@ }, "node_modules/ret": { "version": "0.2.2", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -25361,6 +25467,7 @@ }, "node_modules/rfdc": { "version": "1.3.0", + "dev": true, "license": "MIT" }, "node_modules/rimraf": { @@ -25520,6 +25627,7 @@ }, "node_modules/safe-regex2": { "version": "2.0.0", + "dev": true, "license": "MIT", "dependencies": { "ret": "~0.2.0" @@ -25527,6 +25635,7 @@ }, "node_modules/safe-stable-stringify": { "version": "2.4.3", + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -25555,6 +25664,7 @@ }, "node_modules/scheduler": { "version": "0.23.0", + "dev": true, "license": "MIT", "dependencies": { "loose-envify": "^1.1.0" @@ -25579,6 +25689,7 @@ }, "node_modules/secure-json-parse": { "version": "2.7.0", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/select-hose": { @@ -25793,6 +25904,7 @@ }, "node_modules/set-cookie-parser": { "version": "2.6.0", + "dev": true, "license": "MIT" }, "node_modules/set-function-name": { @@ -25870,6 +25982,7 @@ }, "node_modules/shebang-command": { "version": "2.0.0", + "dev": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -25880,6 +25993,7 @@ }, "node_modules/shebang-regex": { "version": "3.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -26353,6 +26467,7 @@ }, "node_modules/sonic-boom": { "version": "3.3.0", + "dev": true, "license": "MIT", "dependencies": { "atomic-sleep": "^1.0.0" @@ -26887,6 +27002,7 @@ }, "node_modules/strip-ansi": { "version": "6.0.1", + "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" @@ -26948,6 +27064,7 @@ }, "node_modules/strip-json-comments": { "version": "3.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -27459,6 +27576,7 @@ }, "node_modules/text-table": { "version": "0.2.0", + "dev": true, "license": "MIT" }, "node_modules/thenify": { @@ -27482,6 +27600,7 @@ }, "node_modules/thread-stream": { "version": "2.3.0", + "dev": true, "license": "MIT", "dependencies": { "real-require": "^0.2.0" @@ -27554,6 +27673,7 @@ }, "node_modules/tiny-lru": { "version": "10.4.1", + "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=12" @@ -28299,6 +28419,7 @@ }, "node_modules/type-check": { "version": "0.4.0", + "dev": true, "license": "MIT", "dependencies": { "prelude-ls": "^1.2.1" @@ -28317,6 +28438,7 @@ }, "node_modules/type-fest": { "version": "0.20.2", + "dev": true, "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=10" @@ -28414,6 +28536,7 @@ }, "node_modules/typescript": { "version": "4.9.4", + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -28560,7 +28683,7 @@ }, "node_modules/update-browserslist-db": { "version": "1.0.11", - "devOptional": true, + "dev": true, "funding": [ { "type": "opencollective", @@ -28605,6 +28728,7 @@ }, "node_modules/uri-js": { "version": "4.4.1", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" @@ -29413,6 +29537,7 @@ }, "node_modules/which": { "version": "2.0.2", + "dev": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" @@ -29651,6 +29776,7 @@ }, "node_modules/wrappy": { "version": "1.0.2", + "dev": true, "license": "ISC" }, "node_modules/write-file-atomic": { @@ -29797,7 +29923,7 @@ }, "node_modules/yallist": { "version": "3.1.1", - "devOptional": true, + "dev": true, "license": "ISC" }, "node_modules/yaml": { @@ -29883,6 +30009,7 @@ }, "node_modules/yocto-queue": { "version": "0.1.0", + "dev": true, "license": "MIT", "engines": { "node": ">=10" diff --git a/packages/shared/package.json b/packages/shared/package.json index 107fc2be7c..e3fc01ce4e 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -7,8 +7,7 @@ "module": "./dist/esm/index.js", "sideEffects": false, "files": [ - "dist", - "testUtils" + "dist" ], "exports": { ".": { @@ -34,6 +33,11 @@ "test:ci": "jest --maxWorkers=50%", "test:coverage": "jest --collectCoverage && open coverage/lcov-report/index.html" }, + "dependencies": { + "glob-to-regexp": "0.4.1", + "js-cookie": "3.0.1", + "swr": "2.2.0" + }, "devDependencies": { "@clerk/types": "3.54.0", "@types/glob-to-regexp": "0.4.1", @@ -44,14 +48,14 @@ "peerDependencies": { "react": ">=16" }, - "author": "", - "license": "ISC", + "peerDependenciesMeta": { + "react": { + "optional": true + } + }, + "author": "Clerk", + "license": "MIT", "publishConfig": { "access": "public" - }, - "dependencies": { - "glob-to-regexp": "0.4.1", - "js-cookie": "3.0.1", - "swr": "2.2.0" } } From 6c209eac565fb72751191a31febbb1c14f016822 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 10:13:01 +0200 Subject: [PATCH 02/53] chore(repo): Remove testUtils from shared pkg --- packages/clerk-js/setupJestAfterEnv.ts | 10 ---------- .../__tests__/OrganizationMembers.test.tsx | 3 ++- .../__tests__/OrganizationSettings.test.tsx | 3 ++- .../__tests__/useFormattedPhoneNumber.test.ts | 2 +- .../hooks/__tests__/useSupportEmail.test.tsx | 2 +- .../ui/router/__tests__/HashRouter.test.tsx | 3 ++- .../ui/router/__tests__/PathRouter.test.tsx | 3 ++- .../src/ui/router/__tests__/Switch.test.tsx | 2 +- .../ui/router/__tests__/VirtualRouter.test.tsx | 3 ++- .../utils/__tests__/ignoreEventValue.test.ts | 5 +++-- .../components/__tests__/SignInButton.test.tsx | 3 ++- .../SignInWithMetamaskButton.test.tsx | 3 ++- .../__tests__/SignOutButton.test.tsx | 3 ++- .../components/__tests__/SignUpButton.test.tsx | 3 ++- .../useMaxAllowedInstancesGuard.test.tsx | 2 +- packages/shared/package.json | 5 ----- packages/shared/src/testUtils/index.ts | 1 - packages/shared/src/testUtils/testUtils.ts | 18 ------------------ packages/shared/testUtils/package.json | 5 ----- packages/shared/tsconfig.json | 2 +- setupJest.afterEnv.ts | 3 ++- tsconfig.eslint.json | 3 ++- 22 files changed, 30 insertions(+), 57 deletions(-) delete mode 100644 packages/shared/src/testUtils/index.ts delete mode 100644 packages/shared/src/testUtils/testUtils.ts delete mode 100644 packages/shared/testUtils/package.json diff --git a/packages/clerk-js/setupJestAfterEnv.ts b/packages/clerk-js/setupJestAfterEnv.ts index 1c3cb95343..7b0828bfa8 100644 --- a/packages/clerk-js/setupJestAfterEnv.ts +++ b/packages/clerk-js/setupJestAfterEnv.ts @@ -1,11 +1 @@ import '@testing-library/jest-dom'; -// import { afterEach } from '@jest/globals'; -// import { cleanup } from '@testing-library/react'; -// -// /** -// * RTL cannot automatically run cleanup after every test because -// * we're not injecting jest helpers globally. -// * This file is picked up by jest.config.ts and mounts cleanup as RTL would -// * https://github.com/testing-library/testing-library-docs/pull/645 -// */ -// afterEach(cleanup); diff --git a/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationMembers.test.tsx b/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationMembers.test.tsx index 384e418ad2..aaeb0547bb 100644 --- a/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationMembers.test.tsx +++ b/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationMembers.test.tsx @@ -1,6 +1,7 @@ -import { render, userEvent, waitFor } from '@clerk/shared/testUtils'; import type { OrganizationInvitationResource, OrganizationMembershipResource } from '@clerk/types'; import { describe, it } from '@jest/globals'; +import { render, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import { bindCreateFixtures } from '../../../utils/test/createFixtures'; import { runFakeTimers } from '../../../utils/test/runFakeTimers'; diff --git a/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationSettings.test.tsx b/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationSettings.test.tsx index 6f93b98faa..aca900ed50 100644 --- a/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationSettings.test.tsx +++ b/packages/clerk-js/src/ui/components/OrganizationProfile/__tests__/OrganizationSettings.test.tsx @@ -1,6 +1,7 @@ -import { render, userEvent, waitFor } from '@clerk/shared/testUtils'; import type { OrganizationDomainResource, OrganizationMembershipResource } from '@clerk/types'; import { describe, it } from '@jest/globals'; +import { render, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import { bindCreateFixtures } from '../../../utils/test/createFixtures'; import { OrganizationSettings } from '../OrganizationSettings'; diff --git a/packages/clerk-js/src/ui/elements/PhoneInput/__tests__/useFormattedPhoneNumber.test.ts b/packages/clerk-js/src/ui/elements/PhoneInput/__tests__/useFormattedPhoneNumber.test.ts index 0c71dd999a..68c671bced 100644 --- a/packages/clerk-js/src/ui/elements/PhoneInput/__tests__/useFormattedPhoneNumber.test.ts +++ b/packages/clerk-js/src/ui/elements/PhoneInput/__tests__/useFormattedPhoneNumber.test.ts @@ -1,5 +1,5 @@ -import { renderHook } from '@clerk/shared/testUtils'; import { waitFor } from '@testing-library/dom'; +import { renderHook } from '@testing-library/react'; import { useFormattedPhoneNumber } from '../useFormattedPhoneNumber'; diff --git a/packages/clerk-js/src/ui/hooks/__tests__/useSupportEmail.test.tsx b/packages/clerk-js/src/ui/hooks/__tests__/useSupportEmail.test.tsx index 38ab80e6d8..d7c4614d0f 100644 --- a/packages/clerk-js/src/ui/hooks/__tests__/useSupportEmail.test.tsx +++ b/packages/clerk-js/src/ui/hooks/__tests__/useSupportEmail.test.tsx @@ -1,4 +1,4 @@ -import { renderHook } from '@clerk/shared/testUtils'; +import { renderHook } from '@testing-library/react'; import { useSupportEmail } from '../useSupportEmail'; diff --git a/packages/clerk-js/src/ui/router/__tests__/HashRouter.test.tsx b/packages/clerk-js/src/ui/router/__tests__/HashRouter.test.tsx index 68bd6af7dc..a1d79bd9df 100644 --- a/packages/clerk-js/src/ui/router/__tests__/HashRouter.test.tsx +++ b/packages/clerk-js/src/ui/router/__tests__/HashRouter.test.tsx @@ -1,4 +1,5 @@ -import { render, screen, userEvent } from '@clerk/shared/testUtils'; +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import React from 'react'; import type Clerk from '../../../core/clerk'; diff --git a/packages/clerk-js/src/ui/router/__tests__/PathRouter.test.tsx b/packages/clerk-js/src/ui/router/__tests__/PathRouter.test.tsx index e68004d422..f74ef75d03 100644 --- a/packages/clerk-js/src/ui/router/__tests__/PathRouter.test.tsx +++ b/packages/clerk-js/src/ui/router/__tests__/PathRouter.test.tsx @@ -1,4 +1,5 @@ -import { render, screen, userEvent, waitFor } from '@clerk/shared/testUtils'; +import { render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import React from 'react'; import type Clerk from '../../../core/clerk'; diff --git a/packages/clerk-js/src/ui/router/__tests__/Switch.test.tsx b/packages/clerk-js/src/ui/router/__tests__/Switch.test.tsx index 65fcb90f37..ea06285395 100644 --- a/packages/clerk-js/src/ui/router/__tests__/Switch.test.tsx +++ b/packages/clerk-js/src/ui/router/__tests__/Switch.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@clerk/shared/testUtils'; +import { render, screen } from '@testing-library/react'; import React from 'react'; import { HashRouter, Route, Switch } from '../../router'; diff --git a/packages/clerk-js/src/ui/router/__tests__/VirtualRouter.test.tsx b/packages/clerk-js/src/ui/router/__tests__/VirtualRouter.test.tsx index 59e2cda9f9..93d75e57a1 100644 --- a/packages/clerk-js/src/ui/router/__tests__/VirtualRouter.test.tsx +++ b/packages/clerk-js/src/ui/router/__tests__/VirtualRouter.test.tsx @@ -1,4 +1,5 @@ -import { render, screen, userEvent } from '@clerk/shared/testUtils'; +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import React from 'react'; import { Route, useRouter, VirtualRouter } from '..'; diff --git a/packages/clerk-js/src/utils/__tests__/ignoreEventValue.test.ts b/packages/clerk-js/src/utils/__tests__/ignoreEventValue.test.ts index 2e4930d688..5754003e30 100644 --- a/packages/clerk-js/src/utils/__tests__/ignoreEventValue.test.ts +++ b/packages/clerk-js/src/utils/__tests__/ignoreEventValue.test.ts @@ -1,7 +1,8 @@ -import { noop } from '@clerk/shared/testUtils'; - import { ignoreEventValue } from '../ignoreEventValue'; +// eslint-disable-next-line @typescript-eslint/no-empty-function +const noop = (..._args: any[]): void => {}; + describe('ignoreNonEventValue', () => { it('allows non event values', () => { expect(ignoreEventValue(true)).toEqual(true); diff --git a/packages/react/src/components/__tests__/SignInButton.test.tsx b/packages/react/src/components/__tests__/SignInButton.test.tsx index f6bc4f8d45..029a9ceae4 100644 --- a/packages/react/src/components/__tests__/SignInButton.test.tsx +++ b/packages/react/src/components/__tests__/SignInButton.test.tsx @@ -1,4 +1,5 @@ -import { render, screen, userEvent, waitFor } from '@clerk/shared/testUtils'; +import { render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import React from 'react'; import { SignInButton } from '../SignInButton'; diff --git a/packages/react/src/components/__tests__/SignInWithMetamaskButton.test.tsx b/packages/react/src/components/__tests__/SignInWithMetamaskButton.test.tsx index 6d12a6f07f..f1d67639d4 100644 --- a/packages/react/src/components/__tests__/SignInWithMetamaskButton.test.tsx +++ b/packages/react/src/components/__tests__/SignInWithMetamaskButton.test.tsx @@ -1,4 +1,5 @@ -import { render, screen, userEvent, waitFor } from '@clerk/shared/testUtils'; +import { render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import React from 'react'; import { SignInWithMetamaskButton } from '../SignInWithMetamaskButton'; diff --git a/packages/react/src/components/__tests__/SignOutButton.test.tsx b/packages/react/src/components/__tests__/SignOutButton.test.tsx index b71bb15b17..686873c480 100644 --- a/packages/react/src/components/__tests__/SignOutButton.test.tsx +++ b/packages/react/src/components/__tests__/SignOutButton.test.tsx @@ -1,4 +1,5 @@ -import { render, screen, userEvent, waitFor } from '@clerk/shared/testUtils'; +import { render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import React from 'react'; import { SignOutButton } from '../SignOutButton'; diff --git a/packages/react/src/components/__tests__/SignUpButton.test.tsx b/packages/react/src/components/__tests__/SignUpButton.test.tsx index e86f3d552b..7c190d7650 100644 --- a/packages/react/src/components/__tests__/SignUpButton.test.tsx +++ b/packages/react/src/components/__tests__/SignUpButton.test.tsx @@ -1,4 +1,5 @@ -import { render, screen, userEvent, waitFor } from '@clerk/shared/testUtils'; +import { render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import React from 'react'; import { SignUpButton } from '../SignUpButton'; diff --git a/packages/react/src/utils/__tests__/useMaxAllowedInstancesGuard.test.tsx b/packages/react/src/utils/__tests__/useMaxAllowedInstancesGuard.test.tsx index d31442d8f2..ccb7bb8b42 100644 --- a/packages/react/src/utils/__tests__/useMaxAllowedInstancesGuard.test.tsx +++ b/packages/react/src/utils/__tests__/useMaxAllowedInstancesGuard.test.tsx @@ -1,4 +1,4 @@ -import { render } from '@clerk/shared/testUtils'; +import { render } from '@testing-library/react'; import React from 'react'; import { useMaxAllowedInstancesGuard, withMaxAllowedInstancesGuard } from '../useMaxAllowedInstancesGuard'; diff --git a/packages/shared/package.json b/packages/shared/package.json index e3fc01ce4e..d66e3b0bbe 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -14,11 +14,6 @@ "types": "./dist/types/index.d.ts", "import": "./dist/esm/index.js", "require": "./dist/cjs/index.js" - }, - "./testUtils": { - "types": "./dist/types/testUtils/index.d.ts", - "import": "./dist/esm/testUtils/index.js", - "require": "./dist/cjs/testUtils/index.js" } }, "scripts": { diff --git a/packages/shared/src/testUtils/index.ts b/packages/shared/src/testUtils/index.ts deleted file mode 100644 index f6f5b15ff0..0000000000 --- a/packages/shared/src/testUtils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './testUtils'; diff --git a/packages/shared/src/testUtils/testUtils.ts b/packages/shared/src/testUtils/testUtils.ts deleted file mode 100644 index f4f45026c6..0000000000 --- a/packages/shared/src/testUtils/testUtils.ts +++ /dev/null @@ -1,18 +0,0 @@ -import '@testing-library/jest-dom/extend-expect'; - -import type { RenderOptions } from '@testing-library/react'; -import { render } from '@testing-library/react'; - -import { noop } from '../utils'; - -// Wrap components with test providers -const customRender = (ui: React.ReactElement, options?: RenderOptions) => { - return render(ui, options); -}; - -// Re-export everything -export * from '@testing-library/react'; -export { default as userEvent } from '@testing-library/user-event'; - -// Override render method -export { customRender as render, noop }; diff --git a/packages/shared/testUtils/package.json b/packages/shared/testUtils/package.json deleted file mode 100644 index 50671d3b67..0000000000 --- a/packages/shared/testUtils/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "main": "../dist/cjs/testUtils/index.js", - "module": "../dist/esm/testUtils/index.js", - "types": "../dist/types/testUtils/index.d.ts" -} diff --git a/packages/shared/tsconfig.json b/packages/shared/tsconfig.json index 242a1175e6..153c24097f 100644 --- a/packages/shared/tsconfig.json +++ b/packages/shared/tsconfig.json @@ -18,5 +18,5 @@ "lib": ["ES6", "DOM", "WebWorker"] }, "exclude": ["node_modules"], - "include": ["src/index.ts", "src/testUtils/index.ts", "global.d.ts"] + "include": ["src/index.ts", "global.d.ts"] } diff --git a/setupJest.afterEnv.ts b/setupJest.afterEnv.ts index 9ed1580df3..c5e46637f2 100644 --- a/setupJest.afterEnv.ts +++ b/setupJest.afterEnv.ts @@ -1,5 +1,6 @@ -import { beforeAll, afterAll } from '@jest/globals'; +import { afterAll, beforeAll } from '@jest/globals'; +// eslint-disable-next-line @typescript-eslint/unbound-method const ogToLocaleDateString = Date.prototype.toLocaleDateString; beforeAll(() => { diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 3f703b1976..eebd6fd74a 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -11,6 +11,7 @@ "packages/*/*.js", ".eslintrc.js", "commitlint.config.js", - "scripts/*.mjs" + "scripts/*.mjs", + "setupJest.afterEnv.ts" ] } From 46c5b552a59d633aef5464718904cb13b57bfba1 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 10:15:08 +0200 Subject: [PATCH 03/53] chore(shared): Update package.json more --- package-lock.json | 7 ++++++- packages/shared/package.cjs.json | 3 --- packages/shared/package.esm.json | 3 --- packages/shared/package.json | 1 - 4 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 packages/shared/package.cjs.json delete mode 100644 packages/shared/package.esm.json diff --git a/package-lock.json b/package-lock.json index 3bb9daec3a..7ece751684 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30836,7 +30836,7 @@ "packages/shared": { "name": "@clerk/shared", "version": "0.24.3", - "license": "ISC", + "license": "MIT", "dependencies": { "glob-to-regexp": "0.4.1", "js-cookie": "3.0.1", @@ -30851,6 +30851,11 @@ }, "peerDependencies": { "react": ">=16" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + } } }, "packages/themes": { diff --git a/packages/shared/package.cjs.json b/packages/shared/package.cjs.json deleted file mode 100644 index a43829151e..0000000000 --- a/packages/shared/package.cjs.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "sideEffects": false -} diff --git a/packages/shared/package.esm.json b/packages/shared/package.esm.json deleted file mode 100644 index a43829151e..0000000000 --- a/packages/shared/package.esm.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "sideEffects": false -} diff --git a/packages/shared/package.json b/packages/shared/package.json index d66e3b0bbe..e83f3ae85f 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -20,7 +20,6 @@ "build": "tsup", "dev": "tsup --watch", "dev:publish": "npm run dev -- --env.publish", - "build:declarations": "tsc -p tsconfig.json", "publish:local": "npx yalc push --replace --sig", "clean": "rimraf ./dist", "lint": "eslint src/", From b5409e3f9812c6d9acffe4f206948c02b89c5707 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 10:27:52 +0200 Subject: [PATCH 04/53] chore(shared): Jest cleanup --- packages/shared/jest.config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/shared/jest.config.js b/packages/shared/jest.config.js index 959cdc92fc..630e01057e 100644 --- a/packages/shared/jest.config.js +++ b/packages/shared/jest.config.js @@ -6,7 +6,6 @@ const config = { testEnvironment: 'jsdom', roots: ['/src'], setupFiles: ['./setupJest.ts'], - // setupFilesAfterEnv: ['./setupJestAfterEnv.ts'], testRegex: ['/ui/.*/__tests__/.*.test.[jt]sx?$', '/(core|utils)/.*.test.[jt]sx?$'], testPathIgnorePatterns: ['/node_modules/'], @@ -18,7 +17,6 @@ const config = { moduleDirectories: ['node_modules', '/src'], transform: { '^.+\\.m?tsx?$': ['ts-jest', { tsconfig: 'tsconfig.test.json', diagnostics: false }], - // '^.+\\.svg$': '/svgTransform.js', }, }; From ca495896f333042d10dc825e64a2fa24352b01d0 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 11:10:33 +0200 Subject: [PATCH 05/53] chore(shared): Move noop to root --- packages/shared/src/noop.ts | 2 ++ packages/shared/src/utils/createDeferredPromise.ts | 2 +- packages/shared/src/utils/noop.ts | 3 --- packages/shared/src/utils/workerTimers/createWorkerTimers.ts | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 packages/shared/src/noop.ts delete mode 100644 packages/shared/src/utils/noop.ts diff --git a/packages/shared/src/noop.ts b/packages/shared/src/noop.ts new file mode 100644 index 0000000000..d9b9e12b4f --- /dev/null +++ b/packages/shared/src/noop.ts @@ -0,0 +1,2 @@ +// eslint-disable-next-line @typescript-eslint/no-empty-function +export const noop = (..._args: any[]): void => {}; diff --git a/packages/shared/src/utils/createDeferredPromise.ts b/packages/shared/src/utils/createDeferredPromise.ts index 05025b2ca0..8d1c3cc5a7 100644 --- a/packages/shared/src/utils/createDeferredPromise.ts +++ b/packages/shared/src/utils/createDeferredPromise.ts @@ -1,4 +1,4 @@ -import { noop } from './noop'; +import { noop } from '../noop'; type Callback = (val?: any) => void; diff --git a/packages/shared/src/utils/noop.ts b/packages/shared/src/utils/noop.ts deleted file mode 100644 index e65a0290b9..0000000000 --- a/packages/shared/src/utils/noop.ts +++ /dev/null @@ -1,3 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -/* eslint-disable @typescript-eslint/no-empty-function */ -export const noop = (..._args: any[]): void => {}; diff --git a/packages/shared/src/utils/workerTimers/createWorkerTimers.ts b/packages/shared/src/utils/workerTimers/createWorkerTimers.ts index 7c5a1c9d65..bf28bb1938 100644 --- a/packages/shared/src/utils/workerTimers/createWorkerTimers.ts +++ b/packages/shared/src/utils/workerTimers/createWorkerTimers.ts @@ -1,4 +1,4 @@ -import { noop } from '../noop'; +import { noop } from '../../noop'; import type { WorkerClearTimeout, WorkerSetTimeout, From ccd4282af60d6217976199e89f7e6ba586f3a91a Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 11:14:14 +0200 Subject: [PATCH 06/53] chore(shared): Move browser and remove duplicate inClientSide helper --- packages/clerk-js/src/core/clerk.ts | 2 +- packages/clerk-js/src/utils/pageLifecycle.ts | 4 ++-- packages/react/src/isomorphicClerk.ts | 6 +++--- .../src/{utils => __tests__}/browser.test.ts | 2 +- packages/shared/src/{utils => }/browser.ts | 21 +++++++++++++++++++ packages/shared/src/utils/ssr.ts | 3 --- 6 files changed, 28 insertions(+), 10 deletions(-) rename packages/shared/src/{utils => __tests__}/browser.test.ts (99%) rename packages/shared/src/{utils => }/browser.ts (71%) delete mode 100644 packages/shared/src/utils/ssr.ts diff --git a/packages/clerk-js/src/core/clerk.ts b/packages/clerk-js/src/core/clerk.ts index dbde35c213..c0c24e9b24 100644 --- a/packages/clerk-js/src/core/clerk.ts +++ b/packages/clerk-js/src/core/clerk.ts @@ -3,7 +3,7 @@ import { addClerkPrefix, deprecated, handleValueOrFn, - inClientSide, + inBrowser as inClientSide, is4xxError, isHttpOrHttps, isLegacyFrontendApiKey, diff --git a/packages/clerk-js/src/utils/pageLifecycle.ts b/packages/clerk-js/src/utils/pageLifecycle.ts index b127fdc9d8..7f9cd15287 100644 --- a/packages/clerk-js/src/utils/pageLifecycle.ts +++ b/packages/clerk-js/src/utils/pageLifecycle.ts @@ -1,4 +1,4 @@ -import { inClientSide } from '@clerk/shared'; +import { inBrowser } from '@clerk/shared'; const noop = () => { // @@ -15,7 +15,7 @@ const noop = () => { * @internal */ export const createPageLifecycle = () => { - if (!inClientSide()) { + if (!inBrowser()) { return { isUnloading: noop, onPageVisible: noop }; } diff --git a/packages/react/src/isomorphicClerk.ts b/packages/react/src/isomorphicClerk.ts index 16b89c6465..3ebe45f761 100644 --- a/packages/react/src/isomorphicClerk.ts +++ b/packages/react/src/isomorphicClerk.ts @@ -1,4 +1,4 @@ -import { deprecated, handleValueOrFn, inClientSide } from '@clerk/shared'; +import { deprecated, handleValueOrFn, inBrowser } from '@clerk/shared'; import type { ActiveSessionResource, AuthenticateWithMetamaskParams, @@ -93,7 +93,7 @@ export default class IsomorphicClerk { // During CSR: use the cached instance for the whole lifetime of the app // Also will recreate the instance if the provided Clerk instance changes // This method should be idempotent in both scenarios - if (!inClientSide() || !this.#instance || (options.Clerk && this.#instance.Clerk !== options.Clerk)) { + if (!inBrowser() || !this.#instance || (options.Clerk && this.#instance.Clerk !== options.Clerk)) { this.#instance = new IsomorphicClerk(options); } return this.#instance; @@ -131,7 +131,7 @@ export default class IsomorphicClerk { this.#domain = options?.domain; this.options = options; this.Clerk = Clerk; - this.mode = inClientSide() ? 'browser' : 'server'; + this.mode = inBrowser() ? 'browser' : 'server'; void this.loadClerkJS(); } diff --git a/packages/shared/src/utils/browser.test.ts b/packages/shared/src/__tests__/browser.test.ts similarity index 99% rename from packages/shared/src/utils/browser.test.ts rename to packages/shared/src/__tests__/browser.test.ts index ca6a16ce2a..5a801e7d9b 100644 --- a/packages/shared/src/utils/browser.test.ts +++ b/packages/shared/src/__tests__/browser.test.ts @@ -1,4 +1,4 @@ -import { inBrowser, isValidBrowserOnline, userAgentIsRobot } from './browser'; +import { inBrowser, isValidBrowserOnline, userAgentIsRobot } from '../browser'; describe('inBrowser()', () => { it('returns true if window is defined', () => { diff --git a/packages/shared/src/utils/browser.ts b/packages/shared/src/browser.ts similarity index 71% rename from packages/shared/src/utils/browser.ts rename to packages/shared/src/browser.ts index 825e342641..0df2f36f2b 100644 --- a/packages/shared/src/utils/browser.ts +++ b/packages/shared/src/browser.ts @@ -1,3 +1,7 @@ +/** + * Checks if the window object is defined. You can also use this to check if something is happening on the client side. + * @returns {boolean} + */ export function inBrowser(): boolean { return typeof window !== 'undefined'; } @@ -34,10 +38,19 @@ const botAgents = [ ]; const botAgentRegex = new RegExp(botAgents.join('|'), 'i'); +/** + * Checks if the user agent is a bot. + * @param userAgent - Any user agent string + * @returns {boolean} + */ export function userAgentIsRobot(userAgent: string): boolean { return !userAgent ? false : botAgentRegex.test(userAgent); } +/** + * Checks if the current environment is a browser and the user agent is not a bot. + * @returns {boolean} + */ export function isValidBrowser(): boolean { const navigator = window?.navigator; if (!inBrowser() || !navigator) { @@ -46,6 +59,10 @@ export function isValidBrowser(): boolean { return !userAgentIsRobot(navigator?.userAgent) && !navigator?.webdriver; } +/** + * Checks if the current environment is a browser and if the navigator is online. + * @returns {boolean} + */ export function isBrowserOnline(): boolean { const navigator = window?.navigator; if (!inBrowser() || !navigator) { @@ -61,6 +78,10 @@ export function isBrowserOnline(): boolean { return isExperimentalConnectionOnline && isNavigatorOnline; } +/** + * Runs `isBrowserOnline` and `isValidBrowser` to check if the current environment is a valid browser and if the navigator is online. + * @returns {boolean} + */ export function isValidBrowserOnline(): boolean { return isBrowserOnline() && isValidBrowser(); } diff --git a/packages/shared/src/utils/ssr.ts b/packages/shared/src/utils/ssr.ts deleted file mode 100644 index e0ede1979d..0000000000 --- a/packages/shared/src/utils/ssr.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const inClientSide = (): boolean => { - return typeof window !== 'undefined'; -}; From 21ec0efde3141a8bde42cef5872346e3a58a589d Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 11:14:48 +0200 Subject: [PATCH 07/53] chore(shared): Move method helpers into "underscore" file --- .../underscore.test.ts} | 37 +++++++- packages/shared/src/underscore.ts | 84 +++++++++++++++++++ packages/shared/src/utils/array.test.ts | 17 ---- packages/shared/src/utils/array.ts | 12 --- packages/shared/src/utils/object.ts | 48 ----------- packages/shared/src/utils/string.test.ts | 20 ----- packages/shared/src/utils/string.ts | 19 ----- 7 files changed, 120 insertions(+), 117 deletions(-) rename packages/shared/src/{utils/object.test.ts => __tests__/underscore.test.ts} (76%) create mode 100644 packages/shared/src/underscore.ts delete mode 100644 packages/shared/src/utils/array.test.ts delete mode 100644 packages/shared/src/utils/array.ts delete mode 100644 packages/shared/src/utils/object.ts delete mode 100644 packages/shared/src/utils/string.test.ts delete mode 100644 packages/shared/src/utils/string.ts diff --git a/packages/shared/src/utils/object.test.ts b/packages/shared/src/__tests__/underscore.test.ts similarity index 76% rename from packages/shared/src/utils/object.test.ts rename to packages/shared/src/__tests__/underscore.test.ts index 01b42cd456..2398cf84d3 100644 --- a/packages/shared/src/utils/object.test.ts +++ b/packages/shared/src/__tests__/underscore.test.ts @@ -1,4 +1,39 @@ -import { deepCamelToSnake, deepSnakeToCamel } from './object'; +import { deepCamelToSnake, deepSnakeToCamel, isIPV4Address, titleize, toSentence } from '../underscore'; + +describe('toSentence', () => { + it('returns a single item as-is', () => { + expect(toSentence(['xyz'])).toBe('xyz'); + expect(toSentence(['abc'])).toBe('abc'); + }); + + it('joins multiple items but the last with a comma and the last with ", or"', () => { + expect(toSentence(['abc', 'def'])).toBe('abc, or def'); + expect(toSentence(['qwe', 'zxc', 'asd'])).toBe('qwe, zxc, or asd'); + }); + + it('returns empty string if passed an empty array', () => { + expect(toSentence([])).toBe(''); + }); +}); + +describe('isIPV4Address(str)', () => { + it('checks if as string is an IP V4', () => { + expect(isIPV4Address(null)).toBe(false); + expect(isIPV4Address(undefined)).toBe(false); + expect(isIPV4Address('')).toBe(false); + expect(isIPV4Address('127.0.0.1')).toBe(true); + }); +}); + +describe('titleize(str)', () => { + it('titleizes the string', () => { + expect(titleize(null)).toBe(''); + expect(titleize(undefined)).toBe(''); + expect(titleize('')).toBe(''); + expect(titleize('foo')).toBe('Foo'); + expect(titleize('foo bar')).toBe('Foo bar'); + }); +}); describe('camelToSnakeKeys', () => { it('creates a copy and does not modify the original', () => { diff --git a/packages/shared/src/underscore.ts b/packages/shared/src/underscore.ts new file mode 100644 index 0000000000..76a0adca0f --- /dev/null +++ b/packages/shared/src/underscore.ts @@ -0,0 +1,84 @@ +/** + * Converts an array of strings to a comma-separated sentence + * @param items {Array} + * @returns {string} Returns a string with the items joined by a comma and the last item joined by ", or" + */ +export const toSentence = (items: string[]): string => { + // TODO: Once Safari supports it, use Intl.ListFormat + if (items.length == 0) { + return ''; + } + if (items.length == 1) { + return items[0]; + } + let sentence = items.slice(0, -1).join(', '); + sentence += `, or ${items.slice(-1)}`; + return sentence; +}; + +const IP_V4_ADDRESS_REGEX = + /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; + +export function isIPV4Address(str: string | undefined | null): boolean { + return IP_V4_ADDRESS_REGEX.test(str || ''); +} + +export function titleize(str: string | undefined | null): string { + const s = str || ''; + return s.charAt(0).toUpperCase() + s.slice(1); +} + +export function snakeToCamel(str: string | undefined): string { + return str ? str.replace(/([-_][a-z])/g, match => match.toUpperCase().replace(/-|_/, '')) : ''; +} + +export function camelToSnake(str: string | undefined): string { + return str ? str.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`) : ''; +} + +const createDeepObjectTransformer = (transform: any) => { + const deepTransform = (obj: any): any => { + if (!obj) { + return obj; + } + + if (Array.isArray(obj)) { + return obj.map(el => { + if (typeof el === 'object' || Array.isArray(el)) { + return deepTransform(el); + } + return el; + }); + } + + const copy = { ...obj }; + const keys = Object.keys(copy); + for (const oldName of keys) { + const newName = transform(oldName.toString()); + if (newName !== oldName) { + copy[newName] = copy[oldName]; + delete copy[oldName]; + } + if (typeof copy[newName] === 'object') { + copy[newName] = deepTransform(copy[newName]); + } + } + return copy; + }; + + return deepTransform; +}; + +/** + * Transforms camelCased objects/ arrays to snake_cased. + * This function recursively traverses all objects and arrays of the passed value + * camelCased keys are removed. + */ +export const deepCamelToSnake = createDeepObjectTransformer(camelToSnake); + +/** + * Transforms snake_cased objects/ arrays to camelCased. + * This function recursively traverses all objects and arrays of the passed value + * camelCased keys are removed. + */ +export const deepSnakeToCamel = createDeepObjectTransformer(snakeToCamel); diff --git a/packages/shared/src/utils/array.test.ts b/packages/shared/src/utils/array.test.ts deleted file mode 100644 index 98d65d671e..0000000000 --- a/packages/shared/src/utils/array.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { toSentence } from './array'; - -describe('toSentence', () => { - it('returns a single item as-is', () => { - expect(toSentence(['xyz'])).toBe('xyz'); - expect(toSentence(['abc'])).toBe('abc'); - }); - - it('joins multiple items but the last with a comma and the last with ", or"', () => { - expect(toSentence(['abc', 'def'])).toBe('abc, or def'); - expect(toSentence(['qwe', 'zxc', 'asd'])).toBe('qwe, zxc, or asd'); - }); - - it('returns empty string if passed an empty array', () => { - expect(toSentence([])).toBe(''); - }); -}); diff --git a/packages/shared/src/utils/array.ts b/packages/shared/src/utils/array.ts deleted file mode 100644 index 6e72606e37..0000000000 --- a/packages/shared/src/utils/array.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const toSentence = (items: string[]): string => { - // TODO: Once Safari supports it, use Intl.ListFormat - if (items.length == 0) { - return ''; - } - if (items.length == 1) { - return items[0]; - } - let sentence = items.slice(0, -1).join(', '); - sentence += `, or ${items.slice(-1)}`; - return sentence; -}; diff --git a/packages/shared/src/utils/object.ts b/packages/shared/src/utils/object.ts deleted file mode 100644 index 6d9b58b8f4..0000000000 --- a/packages/shared/src/utils/object.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { camelToSnake, snakeToCamel } from './string'; - -const createDeepObjectTransformer = (transform: any) => { - const deepTransform = (obj: any): any => { - if (!obj) { - return obj; - } - - if (Array.isArray(obj)) { - return obj.map(el => { - if (typeof el === 'object' || Array.isArray(el)) { - return deepTransform(el); - } - return el; - }); - } - - const copy = { ...obj }; - const keys = Object.keys(copy); - for (const oldName of keys) { - const newName = transform(oldName.toString()); - if (newName !== oldName) { - copy[newName] = copy[oldName]; - delete copy[oldName]; - } - if (typeof copy[newName] === 'object') { - copy[newName] = deepTransform(copy[newName]); - } - } - return copy; - }; - - return deepTransform; -}; - -/** - * Transforms camelCased objects/ arrays to snake_cased. - * This function recursively traverses all objects and arrays of the passed value - * camelCased keys are removed. - */ -export const deepCamelToSnake = createDeepObjectTransformer(camelToSnake); - -/** - * Transforms snake_cased objects/ arrays to camelCased. - * This function recursively traverses all objects and arrays of the passed value - * camelCased keys are removed. - */ -export const deepSnakeToCamel = createDeepObjectTransformer(snakeToCamel); diff --git a/packages/shared/src/utils/string.test.ts b/packages/shared/src/utils/string.test.ts deleted file mode 100644 index db64e565c1..0000000000 --- a/packages/shared/src/utils/string.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { isIPV4Address, titleize } from './string'; - -describe('isIPV4Address(str)', () => { - it('checks if as string is an IP V4', () => { - expect(isIPV4Address(null)).toBe(false); - expect(isIPV4Address(undefined)).toBe(false); - expect(isIPV4Address('')).toBe(false); - expect(isIPV4Address('127.0.0.1')).toBe(true); - }); -}); - -describe('titleize(str)', () => { - it('titleizes the string', () => { - expect(titleize(null)).toBe(''); - expect(titleize(undefined)).toBe(''); - expect(titleize('')).toBe(''); - expect(titleize('foo')).toBe('Foo'); - expect(titleize('foo bar')).toBe('Foo bar'); - }); -}); diff --git a/packages/shared/src/utils/string.ts b/packages/shared/src/utils/string.ts deleted file mode 100644 index 06f84780be..0000000000 --- a/packages/shared/src/utils/string.ts +++ /dev/null @@ -1,19 +0,0 @@ -const IP_V4_ADDRESS_REGEX = - /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; - -export function isIPV4Address(str: string | undefined | null): boolean { - return IP_V4_ADDRESS_REGEX.test(str || ''); -} - -export function titleize(str: string | undefined | null): string { - const s = str || ''; - return s.charAt(0).toUpperCase() + s.slice(1); -} - -export function snakeToCamel(str: string | undefined): string { - return str ? str.replace(/([-_][a-z])/g, match => match.toUpperCase().replace(/-|_/, '')) : ''; -} - -export function camelToSnake(str: string | undefined): string { - return str ? str.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`) : ''; -} From 03573514c016b8181bf837b8cd03ed5594552d59 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 11:15:08 +0200 Subject: [PATCH 08/53] chore(shared): Move url to root --- packages/shared/src/{utils => __tests__}/url.test.ts | 2 +- packages/shared/src/{utils => }/url.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename packages/shared/src/{utils => __tests__}/url.test.ts (99%) rename packages/shared/src/{utils => }/url.ts (97%) diff --git a/packages/shared/src/utils/url.test.ts b/packages/shared/src/__tests__/url.test.ts similarity index 99% rename from packages/shared/src/utils/url.test.ts rename to packages/shared/src/__tests__/url.test.ts index b26033e4f4..6410f67c83 100644 --- a/packages/shared/src/utils/url.test.ts +++ b/packages/shared/src/__tests__/url.test.ts @@ -1,4 +1,4 @@ -import { addClerkPrefix, parseSearchParams, stripScheme } from './url'; +import { addClerkPrefix, parseSearchParams, stripScheme } from '../url'; describe('parseSearchParams(queryString)', () => { it('parses query string and returns a URLSearchParams object', () => { diff --git a/packages/shared/src/utils/url.ts b/packages/shared/src/url.ts similarity index 97% rename from packages/shared/src/utils/url.ts rename to packages/shared/src/url.ts index c9668586d0..dfadc27ed7 100644 --- a/packages/shared/src/utils/url.ts +++ b/packages/shared/src/url.ts @@ -1,4 +1,4 @@ -import { isStaging } from './instance'; +import { isStaging } from './utils/instance'; export function parseSearchParams(queryString = ''): URLSearchParams { if (queryString.startsWith('?')) { From 707247abe82f95ec7c06a85f28e6cff9b5f4e0f7 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 11:15:29 +0200 Subject: [PATCH 09/53] chore(shared): Fix jest testRegex --- packages/shared/jest.config.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/shared/jest.config.js b/packages/shared/jest.config.js index 630e01057e..aeb14bfe98 100644 --- a/packages/shared/jest.config.js +++ b/packages/shared/jest.config.js @@ -6,13 +6,10 @@ const config = { testEnvironment: 'jsdom', roots: ['/src'], setupFiles: ['./setupJest.ts'], - testRegex: ['/ui/.*/__tests__/.*.test.[jt]sx?$', '/(core|utils)/.*.test.[jt]sx?$'], - testPathIgnorePatterns: ['/node_modules/'], collectCoverage: false, coverageProvider: 'v8', coverageDirectory: 'coverage', - coveragePathIgnorePatterns: ['/node_modules/'], moduleDirectories: ['node_modules', '/src'], transform: { From 3e85dafd2babfb69e57d159426dbfa3a00b9c953 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 11:54:29 +0200 Subject: [PATCH 10/53] chore(shared): Tsup updates --- packages/shared/tsup.config.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/shared/tsup.config.ts b/packages/shared/tsup.config.ts index 31682d8de9..aec902e0ac 100644 --- a/packages/shared/tsup.config.ts +++ b/packages/shared/tsup.config.ts @@ -5,7 +5,6 @@ import type { Options } from 'tsup'; import { defineConfig } from 'tsup'; import { runAfterLast } from '../../scripts/utils'; -// @ts-ignore import { name, version } from './package.json'; export default defineConfig(overrideOptions => { @@ -28,21 +27,15 @@ export default defineConfig(overrideOptions => { }, }; - const onSuccess = (format: 'esm' | 'cjs') => { - return `cp ./package.${format}.json ./dist/${format}/package.json`; - }; - const esm: Options = { ...common, format: 'esm', - onSuccess: onSuccess('esm'), }; const cjs: Options = { ...common, format: 'cjs', outDir: './dist/cjs', - onSuccess: onSuccess('cjs'), }; return runAfterLast(['npm run build:declarations', shouldPublish && 'npm run publish:local'])(esm, cjs); From b6850a2931468a8e413b39454160d3826fa0e4d6 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:19:24 +0200 Subject: [PATCH 11/53] chore(shared): Move color into single file --- .../color.test.ts} | 2 +- .../color/cssColorUtils.ts => color.ts} | 43 +++++++++++++++---- packages/shared/src/utils/color/index.ts | 2 - packages/shared/src/utils/color/predicates.ts | 37 ---------------- 4 files changed, 36 insertions(+), 48 deletions(-) rename packages/shared/src/{utils/color/cssColorUtils.test.ts => __tests__/color.test.ts} (97%) rename packages/shared/src/{utils/color/cssColorUtils.ts => color.ts} (75%) delete mode 100644 packages/shared/src/utils/color/index.ts delete mode 100644 packages/shared/src/utils/color/predicates.ts diff --git a/packages/shared/src/utils/color/cssColorUtils.test.ts b/packages/shared/src/__tests__/color.test.ts similarity index 97% rename from packages/shared/src/utils/color/cssColorUtils.test.ts rename to packages/shared/src/__tests__/color.test.ts index 01ecb4e484..7dc19e3d8c 100644 --- a/packages/shared/src/utils/color/cssColorUtils.test.ts +++ b/packages/shared/src/__tests__/color.test.ts @@ -1,6 +1,6 @@ import type { Color } from '@clerk/types'; -import { colorToSameTypeString, hexStringToRgbaColor, stringToHslaColor, stringToSameTypeColor } from './cssColorUtils'; +import { colorToSameTypeString, hexStringToRgbaColor, stringToHslaColor, stringToSameTypeColor } from '../color'; describe('stringToHslaColor(color)', function () { const hsla = { h: 195, s: 1, l: 0.5 }; diff --git a/packages/shared/src/utils/color/cssColorUtils.ts b/packages/shared/src/color.ts similarity index 75% rename from packages/shared/src/utils/color/cssColorUtils.ts rename to packages/shared/src/color.ts index 71d51f69a4..696a8db2e2 100644 --- a/packages/shared/src/utils/color/cssColorUtils.ts +++ b/packages/shared/src/color.ts @@ -1,13 +1,40 @@ import type { Color, HslaColor, RgbaColor, TransparentColor } from '@clerk/types'; -import { - isHSLColor, - isRGBColor, - isTransparent, - isValidHexString, - isValidHslaString, - isValidRgbaString, -} from './predicates'; +const IS_HEX_COLOR_REGEX = /^#?([A-F0-9]{6}|[A-F0-9]{3})$/i; + +const IS_RGB_COLOR_REGEX = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/i; +const IS_RGBA_COLOR_REGEX = /^rgba\((\d+),\s*(\d+),\s*(\d+)(,\s*\d+(\.\d+)?)\)$/i; + +const IS_HSL_COLOR_REGEX = /^hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)$/i; +const IS_HSLA_COLOR_REGEX = /^hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%(,\s*\d+(\.\d+)?)*\)$/i; + +export const isValidHexString = (s: string) => { + return !!s.match(IS_HEX_COLOR_REGEX); +}; + +export const isValidRgbaString = (s: string) => { + return !!(s.match(IS_RGB_COLOR_REGEX) || s.match(IS_RGBA_COLOR_REGEX)); +}; + +export const isValidHslaString = (s: string) => { + return !!s.match(IS_HSL_COLOR_REGEX) || !!s.match(IS_HSLA_COLOR_REGEX); +}; + +export const isRGBColor = (c: Color): c is RgbaColor => { + return typeof c !== 'string' && 'r' in c; +}; + +export const isHSLColor = (c: Color): c is HslaColor => { + return typeof c !== 'string' && 'h' in c; +}; + +export const isTransparent = (c: Color): c is TransparentColor => { + return c === 'transparent'; +}; + +export const hasAlpha = (color: Color): boolean => { + return typeof color !== 'string' && color.a != undefined && color.a < 1; +}; const CLEAN_HSLA_REGEX = /[hsla()]/g; const CLEAN_RGBA_REGEX = /[rgba()]/g; diff --git a/packages/shared/src/utils/color/index.ts b/packages/shared/src/utils/color/index.ts deleted file mode 100644 index 738532889d..0000000000 --- a/packages/shared/src/utils/color/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './cssColorUtils'; -export * from './predicates'; diff --git a/packages/shared/src/utils/color/predicates.ts b/packages/shared/src/utils/color/predicates.ts deleted file mode 100644 index 1db624d763..0000000000 --- a/packages/shared/src/utils/color/predicates.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type { Color, HslaColor, RgbaColor, TransparentColor } from '@clerk/types'; - -const IS_HEX_COLOR_REGEX = /^#?([A-F0-9]{6}|[A-F0-9]{3})$/i; - -const IS_RGB_COLOR_REGEX = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/i; -const IS_RGBA_COLOR_REGEX = /^rgba\((\d+),\s*(\d+),\s*(\d+)(,\s*\d+(\.\d+)?)\)$/i; - -const IS_HSL_COLOR_REGEX = /^hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)$/i; -const IS_HSLA_COLOR_REGEX = /^hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%(,\s*\d+(\.\d+)?)*\)$/i; - -export const isValidHexString = (s: string) => { - return !!s.match(IS_HEX_COLOR_REGEX); -}; - -export const isValidRgbaString = (s: string) => { - return !!(s.match(IS_RGB_COLOR_REGEX) || s.match(IS_RGBA_COLOR_REGEX)); -}; - -export const isValidHslaString = (s: string) => { - return !!s.match(IS_HSL_COLOR_REGEX) || !!s.match(IS_HSLA_COLOR_REGEX); -}; - -export const isRGBColor = (c: Color): c is RgbaColor => { - return typeof c !== 'string' && 'r' in c; -}; - -export const isHSLColor = (c: Color): c is HslaColor => { - return typeof c !== 'string' && 'h' in c; -}; - -export const isTransparent = (c: Color): c is TransparentColor => { - return c === 'transparent'; -}; - -export const hasAlpha = (color: Color): boolean => { - return typeof color !== 'string' && color.a != undefined && color.a < 1; -}; From 5d776fc42d47e4dee5e959254ce2344c959a6f38 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:20:11 +0200 Subject: [PATCH 12/53] chore(shared): Move proxy to root --- packages/shared/src/{utils => __tests__}/proxy.test.ts | 2 +- packages/shared/src/{utils => }/proxy.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/shared/src/{utils => __tests__}/proxy.test.ts (98%) rename packages/shared/src/{utils => }/proxy.ts (100%) diff --git a/packages/shared/src/utils/proxy.test.ts b/packages/shared/src/__tests__/proxy.test.ts similarity index 98% rename from packages/shared/src/utils/proxy.test.ts rename to packages/shared/src/__tests__/proxy.test.ts index e5b7e2ba47..a34aca2dbe 100644 --- a/packages/shared/src/utils/proxy.test.ts +++ b/packages/shared/src/__tests__/proxy.test.ts @@ -1,4 +1,4 @@ -import { isHttpOrHttps, isProxyUrlRelative, isValidProxyUrl, proxyUrlToAbsoluteURL } from './proxy'; +import { isHttpOrHttps, isProxyUrlRelative, isValidProxyUrl, proxyUrlToAbsoluteURL } from '../proxy'; describe('isValidProxyUrl(key)', () => { it('returns true if the proxyUrl is valid', () => { diff --git a/packages/shared/src/utils/proxy.ts b/packages/shared/src/proxy.ts similarity index 100% rename from packages/shared/src/utils/proxy.ts rename to packages/shared/src/proxy.ts From abb505666491b2338ff61c636acc618c0519d777 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:21:10 +0200 Subject: [PATCH 13/53] chore(shared): Move error stuff into error dir --- packages/shared/src/{errors => error}/Error.ts | 2 +- .../shared/src/{errors => error/__tests__}/thrower.test.ts | 4 ++-- packages/shared/src/{utils/errors.ts => error/checks.ts} | 0 packages/shared/src/error/index.ts | 3 +++ packages/shared/src/{errors => error}/thrower.ts | 0 5 files changed, 6 insertions(+), 3 deletions(-) rename packages/shared/src/{errors => error}/Error.ts (99%) rename packages/shared/src/{errors => error/__tests__}/thrower.test.ts (93%) rename packages/shared/src/{utils/errors.ts => error/checks.ts} (100%) create mode 100644 packages/shared/src/error/index.ts rename packages/shared/src/{errors => error}/thrower.ts (100%) diff --git a/packages/shared/src/errors/Error.ts b/packages/shared/src/error/Error.ts similarity index 99% rename from packages/shared/src/errors/Error.ts rename to packages/shared/src/error/Error.ts index 066dffa627..4dcdd1ada4 100644 --- a/packages/shared/src/errors/Error.ts +++ b/packages/shared/src/error/Error.ts @@ -1,6 +1,6 @@ import type { ClerkAPIError, ClerkAPIErrorJSON } from '@clerk/types'; -import { deprecated } from '../utils'; +import { deprecated } from '../deprecated'; interface ClerkAPIResponseOptions { data: ClerkAPIErrorJSON[]; diff --git a/packages/shared/src/errors/thrower.test.ts b/packages/shared/src/error/__tests__/thrower.test.ts similarity index 93% rename from packages/shared/src/errors/thrower.test.ts rename to packages/shared/src/error/__tests__/thrower.test.ts index 33bbf11c71..73c62d7bfd 100644 --- a/packages/shared/src/errors/thrower.test.ts +++ b/packages/shared/src/error/__tests__/thrower.test.ts @@ -1,5 +1,5 @@ -import type { ErrorThrowerOptions } from './thrower'; -import { buildErrorThrower } from './thrower'; +import type { ErrorThrowerOptions } from '../thrower'; +import { buildErrorThrower } from '../thrower'; describe('ErrorThrower', () => { const errorThrower = buildErrorThrower({ packageName: '@clerk/test-package' }); diff --git a/packages/shared/src/utils/errors.ts b/packages/shared/src/error/checks.ts similarity index 100% rename from packages/shared/src/utils/errors.ts rename to packages/shared/src/error/checks.ts diff --git a/packages/shared/src/error/index.ts b/packages/shared/src/error/index.ts new file mode 100644 index 0000000000..54c1fbe792 --- /dev/null +++ b/packages/shared/src/error/index.ts @@ -0,0 +1,3 @@ +export * from './checks'; +export * from './Error'; +export * from './thrower'; diff --git a/packages/shared/src/errors/thrower.ts b/packages/shared/src/error/thrower.ts similarity index 100% rename from packages/shared/src/errors/thrower.ts rename to packages/shared/src/error/thrower.ts From c53ad69205f6b245906b9f334ab45c0c572d4ed0 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:21:33 +0200 Subject: [PATCH 14/53] chore(shared): Move date to root --- packages/shared/src/__tests__/date.test.ts | 68 ++++++++++++++++++++++ packages/shared/src/{utils => }/date.ts | 3 +- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 packages/shared/src/__tests__/date.test.ts rename packages/shared/src/{utils => }/date.ts (95%) diff --git a/packages/shared/src/__tests__/date.test.ts b/packages/shared/src/__tests__/date.test.ts new file mode 100644 index 0000000000..56acc62117 --- /dev/null +++ b/packages/shared/src/__tests__/date.test.ts @@ -0,0 +1,68 @@ +import type { RelativeDateCase } from '../date'; +import { addYears, dateTo12HourTime, differenceInCalendarDays, formatRelative } from '../date'; + +describe('date utils', () => { + describe('dateTo12HourTime(date)', () => { + const cases: Array<[Date | undefined, string]> = [ + [undefined, ''], + [new Date('1/1/2020 23:15'), '11:15 PM'], + [new Date('1/1/2020 11:15'), '11:15 AM'], + [new Date('1/1/2020 01:59'), '01:59 AM'], + [new Date('1/1/2020 13:59'), '01:59 PM'], + [new Date('1/1/2020 00:59'), '12:59 AM'], + ]; + + it.each(cases)('.dateTo12HourTime(%s) => %s', (a, expected) => { + expect(dateTo12HourTime(a as any)).toBe(expected); + }); + }); + + describe('differenceInCalendarDays(date1, date2)', () => { + const cases: Array<[Date | undefined, Date, { absolute: boolean }, number]> = [ + [undefined, new Date(), { absolute: true }, 0], + [new Date('1/1/2020'), new Date('1/2/2020'), { absolute: true }, 1], + [new Date('1/1/2020'), new Date('1/3/2020'), { absolute: true }, 2], + [new Date('1/30/2020'), new Date('1/31/2020'), { absolute: true }, 1], + [new Date('1/30/2020'), new Date('2/1/2020'), { absolute: true }, 2], + [new Date('1/1/2020'), new Date('2/1/2020'), { absolute: true }, 31], + [new Date('1/1/2020'), new Date('1/2/2020'), { absolute: false }, 1], + [new Date('1/1/2020'), new Date('1/5/2020'), { absolute: false }, 4], + [new Date('1/5/2020'), new Date('1/1/2020'), { absolute: true }, 4], + [new Date('1/5/2020'), new Date('1/1/2020'), { absolute: false }, -4], + ]; + + it.each(cases)('.differenceInCalendarDays(%s,%s) => %s', (a, b, c, expected) => { + expect(differenceInCalendarDays(a as Date, b, c)).toBe(expected); + }); + }); + + describe('formatRelative(date)', () => { + const cases: Array<[Date | undefined, Date | undefined, RelativeDateCase | null]> = [ + [undefined, undefined, null], + [new Date('1/1/2020 23:15'), new Date('1/1/2020'), 'sameDay'], + [new Date('1/5/2020 23:15'), new Date('1/6/2020'), 'lastDay'], + [new Date('1/3/2020 23:15'), new Date('1/6/2020'), 'previous6Days'], + [new Date('1/7/2020 23:15'), new Date('1/6/2020'), 'nextDay'], + [new Date('1/10/2020 23:15'), new Date('1/6/2020'), 'next6Days'], + [new Date('12/10/2020 23:15'), new Date('1/6/2020'), 'other'], + [new Date('12/10/2020 23:15'), new Date('1/6/2021'), 'other'], + ]; + + it.each(cases)('.formatRelative(%s, %s) => %s', (a, b, expected) => { + expect(formatRelative({ date: a as Date, relativeTo: b as Date })?.relativeDateCase || null).toBe(expected); + }); + }); + + describe('addYears(date, number)', () => { + const cases: Array<[Date, number, Date]> = [ + [new Date('1/1/2020 23:15'), 1, new Date('1/1/2021 23:15')], + [new Date('1/1/2019 23:15'), 1, new Date('1/1/2020 23:15')], + [new Date('1/1/2021 23:15'), 100, new Date('1/1/2121 23:15')], + [new Date('1/1/2021 23:15'), 0, new Date('1/1/2021 23:15')], + ]; + + it.each(cases)('.addYears(%s, %s) => %s', (a, b, expected) => { + expect(addYears(a, b)).toStrictEqual(expected); + }); + }); +}); diff --git a/packages/shared/src/utils/date.ts b/packages/shared/src/date.ts similarity index 95% rename from packages/shared/src/utils/date.ts rename to packages/shared/src/date.ts index 4ef305220a..73442627d1 100644 --- a/packages/shared/src/utils/date.ts +++ b/packages/shared/src/date.ts @@ -34,8 +34,9 @@ type DateFormatRelativeParams = { relativeTo: Date | string | number; }; -type RelativeDateCase = 'previous6Days' | 'lastDay' | 'sameDay' | 'nextDay' | 'next6Days' | 'other'; +export type RelativeDateCase = 'previous6Days' | 'lastDay' | 'sameDay' | 'nextDay' | 'next6Days' | 'other'; type RelativeDateReturn = { relativeDateCase: RelativeDateCase; date: Date } | null; + export function formatRelative(props: DateFormatRelativeParams): RelativeDateReturn { const { date, relativeTo } = props; if (!date || !relativeTo) { From 6fdeaf5ae62141789c42e63fc164ebfa9e70cbd7 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:22:29 +0200 Subject: [PATCH 15/53] chore(shared): Move keys to root --- packages/shared/src/{utils => __tests__}/keys.test.ts | 4 +++- packages/shared/src/{utils => }/keys.ts | 0 2 files changed, 3 insertions(+), 1 deletion(-) rename packages/shared/src/{utils => __tests__}/keys.test.ts (98%) rename packages/shared/src/{utils => }/keys.ts (100%) diff --git a/packages/shared/src/utils/keys.test.ts b/packages/shared/src/__tests__/keys.test.ts similarity index 98% rename from packages/shared/src/utils/keys.test.ts rename to packages/shared/src/__tests__/keys.test.ts index 703d1b9826..5867c95e97 100644 --- a/packages/shared/src/utils/keys.test.ts +++ b/packages/shared/src/__tests__/keys.test.ts @@ -4,7 +4,7 @@ import { isLegacyFrontendApiKey, isPublishableKey, parsePublishableKey, -} from './keys'; +} from '../keys'; describe('buildPublishableKey(key)', () => { const cases = [ @@ -37,7 +37,9 @@ describe('parsePublishableKey(key)', () => { ], ]; + // @ts-ignore test.each(cases)('given %p as a publishable key string, returns %p', (publishableKeyStr, expectedPublishableKey) => { + // @ts-ignore const result = parsePublishableKey(publishableKeyStr); expect(result).toEqual(expectedPublishableKey); }); diff --git a/packages/shared/src/utils/keys.ts b/packages/shared/src/keys.ts similarity index 100% rename from packages/shared/src/utils/keys.ts rename to packages/shared/src/keys.ts From 30391c4f0c8bfa5f0e34d0027b68160f96d632f6 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:23:10 +0200 Subject: [PATCH 16/53] chore(shared): Move deprecated to root --- .../{utils => __tests__}/deprecated.test.ts | 6 +- packages/shared/src/{utils => }/deprecated.ts | 2 +- packages/shared/src/utils/date.test.ts | 68 ------------------- 3 files changed, 4 insertions(+), 72 deletions(-) rename packages/shared/src/{utils => __tests__}/deprecated.test.ts (98%) rename packages/shared/src/{utils => }/deprecated.ts (96%) delete mode 100644 packages/shared/src/utils/date.test.ts diff --git a/packages/shared/src/utils/deprecated.test.ts b/packages/shared/src/__tests__/deprecated.test.ts similarity index 98% rename from packages/shared/src/utils/deprecated.test.ts rename to packages/shared/src/__tests__/deprecated.test.ts index 907f9ced45..3dc26ad20f 100644 --- a/packages/shared/src/utils/deprecated.test.ts +++ b/packages/shared/src/__tests__/deprecated.test.ts @@ -1,12 +1,12 @@ -jest.mock('./runtimeEnvironment', () => { +jest.mock('../utils/runtimeEnvironment', () => { return { isTestEnvironment: jest.fn(() => false), isProductionEnvironment: jest.fn(() => false), }; }); -import { deprecated, deprecatedObjectProperty, deprecatedProperty } from './deprecated'; -import { isProductionEnvironment, isTestEnvironment } from './runtimeEnvironment'; +import { deprecated, deprecatedObjectProperty, deprecatedProperty } from '../deprecated'; +import { isProductionEnvironment, isTestEnvironment } from '../utils/runtimeEnvironment'; describe('deprecated(fnName, warning)', () => { let consoleWarnSpy; diff --git a/packages/shared/src/utils/deprecated.ts b/packages/shared/src/deprecated.ts similarity index 96% rename from packages/shared/src/utils/deprecated.ts rename to packages/shared/src/deprecated.ts index 19ea73cb5c..d79a69f917 100644 --- a/packages/shared/src/utils/deprecated.ts +++ b/packages/shared/src/deprecated.ts @@ -1,4 +1,4 @@ -import { isProductionEnvironment, isTestEnvironment } from './runtimeEnvironment'; +import { isProductionEnvironment, isTestEnvironment } from './utils/runtimeEnvironment'; /** * Mark class method / function as deprecated. * diff --git a/packages/shared/src/utils/date.test.ts b/packages/shared/src/utils/date.test.ts deleted file mode 100644 index 2bfc288e96..0000000000 --- a/packages/shared/src/utils/date.test.ts +++ /dev/null @@ -1,68 +0,0 @@ -import type { RelativeDateCase } from './date'; -import { addYears, dateTo12HourTime, differenceInCalendarDays, formatRelative } from './date'; - -describe('date utils', () => { - describe('dateTo12HourTime(date)', () => { - const cases: Array<[Date | undefined, string]> = [ - [undefined, ''], - [new Date('1/1/2020 23:15'), '11:15 PM'], - [new Date('1/1/2020 11:15'), '11:15 AM'], - [new Date('1/1/2020 01:59'), '01:59 AM'], - [new Date('1/1/2020 13:59'), '01:59 PM'], - [new Date('1/1/2020 00:59'), '12:59 AM'], - ]; - - it.each(cases)('.dateTo12HourTime(%s) => %s', (a, expected) => { - expect(dateTo12HourTime(a as any)).toBe(expected); - }); - }); - - describe('differenceInCalendarDays(date1, date2)', () => { - const cases: Array<[Date | undefined, Date, { absolute: boolean }, number]> = [ - [undefined, new Date(), { absolute: true }, 0], - [new Date('1/1/2020'), new Date('1/2/2020'), { absolute: true }, 1], - [new Date('1/1/2020'), new Date('1/3/2020'), { absolute: true }, 2], - [new Date('1/30/2020'), new Date('1/31/2020'), { absolute: true }, 1], - [new Date('1/30/2020'), new Date('2/1/2020'), { absolute: true }, 2], - [new Date('1/1/2020'), new Date('2/1/2020'), { absolute: true }, 31], - [new Date('1/1/2020'), new Date('1/2/2020'), { absolute: false }, 1], - [new Date('1/1/2020'), new Date('1/5/2020'), { absolute: false }, 4], - [new Date('1/5/2020'), new Date('1/1/2020'), { absolute: true }, 4], - [new Date('1/5/2020'), new Date('1/1/2020'), { absolute: false }, -4], - ]; - - it.each(cases)('.differenceInCalendarDays(%s,%s) => %s', (a, b, c, expected) => { - expect(differenceInCalendarDays(a as Date, b, c)).toBe(expected); - }); - }); - - describe('formatRelative(date)', () => { - const cases: Array<[Date | undefined, Date | undefined, RelativeDateCase | null]> = [ - [undefined, undefined, null], - [new Date('1/1/2020 23:15'), new Date('1/1/2020'), 'sameDay'], - [new Date('1/5/2020 23:15'), new Date('1/6/2020'), 'lastDay'], - [new Date('1/3/2020 23:15'), new Date('1/6/2020'), 'previous6Days'], - [new Date('1/7/2020 23:15'), new Date('1/6/2020'), 'nextDay'], - [new Date('1/10/2020 23:15'), new Date('1/6/2020'), 'next6Days'], - [new Date('12/10/2020 23:15'), new Date('1/6/2020'), 'other'], - [new Date('12/10/2020 23:15'), new Date('1/6/2021'), 'other'], - ]; - - it.each(cases)('.formatRelative(%s, %s) => %s', (a, b, expected) => { - expect(formatRelative({ date: a as Date, relativeTo: b as Date })?.relativeDateCase || null).toBe(expected); - }); - }); - - describe('addYears(date, number)', () => { - const cases: Array<[Date, number, Date]> = [ - [new Date('1/1/2020 23:15'), 1, new Date('1/1/2021 23:15')], - [new Date('1/1/2019 23:15'), 1, new Date('1/1/2020 23:15')], - [new Date('1/1/2021 23:15'), 100, new Date('1/1/2121 23:15')], - [new Date('1/1/2021 23:15'), 0, new Date('1/1/2021 23:15')], - ]; - - it.each(cases)('.addYears(%s, %s) => %s', (a, b, expected) => { - expect(addYears(a, b)).toStrictEqual(expected); - }); - }); -}); From 6477433dd63f87aa5b53792902b4fac509f6582a Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:23:30 +0200 Subject: [PATCH 17/53] chore(shared): Move isomorphicAtob to root --- packages/shared/src/{utils => }/isomorphicAtob.ts | 4 ++++ 1 file changed, 4 insertions(+) rename packages/shared/src/{utils => }/isomorphicAtob.ts (56%) diff --git a/packages/shared/src/utils/isomorphicAtob.ts b/packages/shared/src/isomorphicAtob.ts similarity index 56% rename from packages/shared/src/utils/isomorphicAtob.ts rename to packages/shared/src/isomorphicAtob.ts index 4399e0cc31..c6adaeb9a7 100644 --- a/packages/shared/src/utils/isomorphicAtob.ts +++ b/packages/shared/src/isomorphicAtob.ts @@ -1,3 +1,7 @@ +/** + * A function that decodes a string of data which has been encoded using base-64 encoding. + * Uses `atob` if available, otherwise uses `Buffer` from `global`. If neither are available, returns the data as-is. + */ export const isomorphicAtob = (data: string) => { if (typeof atob !== 'undefined' && typeof atob === 'function') { return atob(data); From ea774b64f957647b5e52aa0302fce4cf788769ea Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:23:53 +0200 Subject: [PATCH 18/53] chore(shared): Move cookie to folder --- packages/shared/src/{utils/cookies.ts => cookie/index.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/shared/src/{utils/cookies.ts => cookie/index.ts} (100%) diff --git a/packages/shared/src/utils/cookies.ts b/packages/shared/src/cookie/index.ts similarity index 100% rename from packages/shared/src/utils/cookies.ts rename to packages/shared/src/cookie/index.ts From 74ddfcb9adf011bfca236a50d7bf2ad10db1a86c Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:57:23 +0200 Subject: [PATCH 19/53] chore(shared): Move workerTimers --- .../shared/src/{utils => }/workerTimers/createWorkerTimers.ts | 2 +- packages/shared/src/{utils => }/workerTimers/index.ts | 0 .../shared/src/{utils => }/workerTimers/workerTimers.types.ts | 0 .../shared/src/{utils => }/workerTimers/workerTimers.worker.ts | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename packages/shared/src/{utils => }/workerTimers/createWorkerTimers.ts (98%) rename packages/shared/src/{utils => }/workerTimers/index.ts (100%) rename packages/shared/src/{utils => }/workerTimers/workerTimers.types.ts (100%) rename packages/shared/src/{utils => }/workerTimers/workerTimers.worker.ts (100%) diff --git a/packages/shared/src/utils/workerTimers/createWorkerTimers.ts b/packages/shared/src/workerTimers/createWorkerTimers.ts similarity index 98% rename from packages/shared/src/utils/workerTimers/createWorkerTimers.ts rename to packages/shared/src/workerTimers/createWorkerTimers.ts index bf28bb1938..7c5a1c9d65 100644 --- a/packages/shared/src/utils/workerTimers/createWorkerTimers.ts +++ b/packages/shared/src/workerTimers/createWorkerTimers.ts @@ -1,4 +1,4 @@ -import { noop } from '../../noop'; +import { noop } from '../noop'; import type { WorkerClearTimeout, WorkerSetTimeout, diff --git a/packages/shared/src/utils/workerTimers/index.ts b/packages/shared/src/workerTimers/index.ts similarity index 100% rename from packages/shared/src/utils/workerTimers/index.ts rename to packages/shared/src/workerTimers/index.ts diff --git a/packages/shared/src/utils/workerTimers/workerTimers.types.ts b/packages/shared/src/workerTimers/workerTimers.types.ts similarity index 100% rename from packages/shared/src/utils/workerTimers/workerTimers.types.ts rename to packages/shared/src/workerTimers/workerTimers.types.ts diff --git a/packages/shared/src/utils/workerTimers/workerTimers.worker.ts b/packages/shared/src/workerTimers/workerTimers.worker.ts similarity index 100% rename from packages/shared/src/utils/workerTimers/workerTimers.worker.ts rename to packages/shared/src/workerTimers/workerTimers.worker.ts From 797c495efb160c65d88f25a8ae76401f8f3131b0 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 12:59:45 +0200 Subject: [PATCH 20/53] chore(shared): Move file and remove mimeTypeExtensions --- packages/shared/src/{utils => }/file.ts | 15 +++++++++++++++ packages/shared/src/utils/mimeTypeExtensions.ts | 14 -------------- 2 files changed, 15 insertions(+), 14 deletions(-) rename packages/shared/src/{utils => }/file.ts (55%) delete mode 100644 packages/shared/src/utils/mimeTypeExtensions.ts diff --git a/packages/shared/src/utils/file.ts b/packages/shared/src/file.ts similarity index 55% rename from packages/shared/src/utils/file.ts rename to packages/shared/src/file.ts index 82dc23a713..88c4f85c3d 100644 --- a/packages/shared/src/utils/file.ts +++ b/packages/shared/src/file.ts @@ -16,3 +16,18 @@ export function readJSONFile(file: File): Promise { reader.readAsText(file); }); } + +const MimeTypeToExtensionMap = Object.freeze({ + 'image/png': 'png', + 'image/jpeg': 'jpg', + 'image/gif': 'gif', + 'image/webp': 'webp', + 'image/x-icon': 'ico', + 'image/vnd.microsoft.icon': 'ico', +} as const); + +export type SupportedMimeType = keyof typeof MimeTypeToExtensionMap; + +export const extension = (mimeType: SupportedMimeType): string => { + return MimeTypeToExtensionMap[mimeType]; +}; diff --git a/packages/shared/src/utils/mimeTypeExtensions.ts b/packages/shared/src/utils/mimeTypeExtensions.ts deleted file mode 100644 index 3d206056ad..0000000000 --- a/packages/shared/src/utils/mimeTypeExtensions.ts +++ /dev/null @@ -1,14 +0,0 @@ -const MimeTypeToExtensionMap = Object.freeze({ - 'image/png': 'png', - 'image/jpeg': 'jpg', - 'image/gif': 'gif', - 'image/webp': 'webp', - 'image/x-icon': 'ico', - 'image/vnd.microsoft.icon': 'ico', -} as const); - -export type SupportedMimeType = keyof typeof MimeTypeToExtensionMap; - -export const extension = (mimeType: SupportedMimeType): string => { - return MimeTypeToExtensionMap[mimeType]; -}; From 235e2e09a752dac5c2ef9bf2db57b995d1fdba67 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 13:08:25 +0200 Subject: [PATCH 21/53] chore(shared): Move cookie and globs --- packages/shared/src/{cookie/index.ts => cookie.ts} | 0 packages/shared/src/{utils => }/globs.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename packages/shared/src/{cookie/index.ts => cookie.ts} (100%) rename packages/shared/src/{utils => }/globs.ts (100%) diff --git a/packages/shared/src/cookie/index.ts b/packages/shared/src/cookie.ts similarity index 100% rename from packages/shared/src/cookie/index.ts rename to packages/shared/src/cookie.ts diff --git a/packages/shared/src/utils/globs.ts b/packages/shared/src/globs.ts similarity index 100% rename from packages/shared/src/utils/globs.ts rename to packages/shared/src/globs.ts From c6788747162c3e2f11caf3a07d4c211719e8c457 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 13:09:02 +0200 Subject: [PATCH 22/53] chore(shared): Tsup ignore test files --- packages/shared/tsup.config.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/shared/tsup.config.ts b/packages/shared/tsup.config.ts index aec902e0ac..35d574b18e 100644 --- a/packages/shared/tsup.config.ts +++ b/packages/shared/tsup.config.ts @@ -12,13 +12,14 @@ export default defineConfig(overrideOptions => { const shouldPublish = !!overrideOptions.env?.publish; const common: Options = { - entry: ['./src/**/*.{ts,tsx,js,jsx}'], + entry: ['./src/**/*.{ts,tsx}', '!./src/**/*.test.{ts,tsx}'], bundle: false, clean: true, minify: false, sourcemap: true, legacyOutput: true, - external: ['@testing-library', 'react', 'jest', 'jest-environment-jsdom', 'react-dom'], + dts: true, + external: ['react', 'react-dom'], esbuildPlugins: [WebWorkerMinifyPlugin as any], define: { PACKAGE_NAME: `"${name}"`, @@ -38,7 +39,7 @@ export default defineConfig(overrideOptions => { outDir: './dist/cjs', }; - return runAfterLast(['npm run build:declarations', shouldPublish && 'npm run publish:local'])(esm, cjs); + return runAfterLast([shouldPublish && 'npm run publish:local'])(esm, cjs); }); // Read transform and minify any files ending in .worker.ts From e271a807cb23c0062f6ded2e832284e16b1b31c2 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 13:30:37 +0200 Subject: [PATCH 23/53] chore(shared): Move rest of files to root --- .../localStorageBroadcastChannel.test.ts | 2 +- packages/shared/src/index.ts | 56 ++++++++----------- packages/shared/src/{utils => }/loadScript.ts | 0 .../localStorageBroadcastChannel.ts | 0 packages/shared/src/{utils => }/poller.ts | 0 .../utils/{ => __tests__}/multiDomain.test.ts | 2 +- .../shared/src/utils/createDeferredPromise.ts | 2 +- packages/shared/src/utils/index.ts | 29 ++-------- packages/shared/src/{ => utils}/noop.ts | 0 .../src/workerTimers/createWorkerTimers.ts | 2 +- 10 files changed, 32 insertions(+), 61 deletions(-) rename packages/shared/src/{utils => __tests__}/localStorageBroadcastChannel.test.ts (94%) rename packages/shared/src/{utils => }/loadScript.ts (100%) rename packages/shared/src/{utils => }/localStorageBroadcastChannel.ts (100%) rename packages/shared/src/{utils => }/poller.ts (100%) rename packages/shared/src/utils/{ => __tests__}/multiDomain.test.ts (94%) rename packages/shared/src/{ => utils}/noop.ts (100%) diff --git a/packages/shared/src/utils/localStorageBroadcastChannel.test.ts b/packages/shared/src/__tests__/localStorageBroadcastChannel.test.ts similarity index 94% rename from packages/shared/src/utils/localStorageBroadcastChannel.test.ts rename to packages/shared/src/__tests__/localStorageBroadcastChannel.test.ts index 3f576f1411..110ef7e053 100644 --- a/packages/shared/src/utils/localStorageBroadcastChannel.test.ts +++ b/packages/shared/src/__tests__/localStorageBroadcastChannel.test.ts @@ -1,4 +1,4 @@ -import { LocalStorageBroadcastChannel } from './localStorageBroadcastChannel'; +import { LocalStorageBroadcastChannel } from '../localStorageBroadcastChannel'; const bcName = 'clerk'; diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index e2fbe82050..24d1f3a775 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -1,34 +1,26 @@ -/** - * Errors +/** The following files are not exported on purpose: + * - cookie.ts + * - globs.ts + * + * The following folders are also not exported on purpose: + * - error + * - react + * - utils + * + * People should always use @clerk/shared/ instead */ -export { buildErrorThrower } from './errors/thrower'; -export type { ErrorThrower, ErrorThrowerOptions } from './errors/thrower'; -export * from './errors/Error'; - -/** - * Utils - */ -export * from './utils'; - -/** - * Hooks - */ -export { assertContextExists, createContextAndHook } from './hooks/createContextAndHook'; -export { useOrganization } from './hooks/useOrganization'; -export { useOrganizationList } from './hooks/useOrganizationList'; -export { useOrganizations } from './hooks/useOrganizations'; -export { useSafeLayoutEffect } from './hooks/useSafeLayoutEffect'; -export { - ClerkInstanceContext, - ClientContext, - OrganizationContext, - OrganizationProvider, - SessionContext, - useClerkInstanceContext, - useClientContext, - useOrganizationContext, - UserContext, - useSessionContext, - useUserContext, -} from './hooks/contexts'; +export { createWorkerTimers } from './workerTimers'; +export * from './browser'; +export * from './color'; +export * from './date'; +export * from './deprecated'; +export * from './file'; +export { isomorphicAtob } from './isomorphicAtob'; +export * from './keys'; +export { loadScript } from './loadScript'; +export { LocalStorageBroadcastChannel } from './localStorageBroadcastChannel'; +export * from './poller'; +export * from './proxy'; +export * from './underscore'; +export * from './url'; diff --git a/packages/shared/src/utils/loadScript.ts b/packages/shared/src/loadScript.ts similarity index 100% rename from packages/shared/src/utils/loadScript.ts rename to packages/shared/src/loadScript.ts diff --git a/packages/shared/src/utils/localStorageBroadcastChannel.ts b/packages/shared/src/localStorageBroadcastChannel.ts similarity index 100% rename from packages/shared/src/utils/localStorageBroadcastChannel.ts rename to packages/shared/src/localStorageBroadcastChannel.ts diff --git a/packages/shared/src/utils/poller.ts b/packages/shared/src/poller.ts similarity index 100% rename from packages/shared/src/utils/poller.ts rename to packages/shared/src/poller.ts diff --git a/packages/shared/src/utils/multiDomain.test.ts b/packages/shared/src/utils/__tests__/multiDomain.test.ts similarity index 94% rename from packages/shared/src/utils/multiDomain.test.ts rename to packages/shared/src/utils/__tests__/multiDomain.test.ts index 613634ed3d..1f9c8694ef 100644 --- a/packages/shared/src/utils/multiDomain.test.ts +++ b/packages/shared/src/utils/__tests__/multiDomain.test.ts @@ -1,4 +1,4 @@ -import { handleValueOrFn } from './multiDomain'; +import { handleValueOrFn } from '../multiDomain'; const url = new URL('https://example.com'); diff --git a/packages/shared/src/utils/createDeferredPromise.ts b/packages/shared/src/utils/createDeferredPromise.ts index 8d1c3cc5a7..05025b2ca0 100644 --- a/packages/shared/src/utils/createDeferredPromise.ts +++ b/packages/shared/src/utils/createDeferredPromise.ts @@ -1,4 +1,4 @@ -import { noop } from '../noop'; +import { noop } from './noop'; type Callback = (val?: any) => void; diff --git a/packages/shared/src/utils/index.ts b/packages/shared/src/utils/index.ts index 25f7edca19..0d4ef5662a 100644 --- a/packages/shared/src/utils/index.ts +++ b/packages/shared/src/utils/index.ts @@ -1,28 +1,7 @@ -export * from './array'; -export * from './browser'; -export * from './color'; -export * from './cookies'; +export { callWithRetry } from './callWithRetry'; export * from './createDeferredPromise'; -export * from './date'; -export * from './errors'; -export * from './file'; -export * from './keys'; -export * from './localStorageBroadcastChannel'; -export * from './mimeTypeExtensions'; +export { isDevelopmentFromApiKey, isProductionFromApiKey, isStaging } from './instance'; export * from './multiDomain'; -export * from './noop'; -export * from './object'; -export * from './poller'; -export * from './proxy'; -export * from './ssr'; -export * from './string'; -export * from './url'; -export * from './workerTimers'; -export * from './runWithExponentialBackOff'; -export * from './isomorphicAtob'; -export * from './globs'; -export * from './loadScript'; +export { noop } from './noop'; export * from './runtimeEnvironment'; -export { deprecated, deprecatedProperty, deprecatedObjectProperty } from './deprecated'; -export { callWithRetry } from './callWithRetry'; -export { isDevelopmentFromApiKey, isProductionFromApiKey, isStaging } from './instance'; +export * from './runWithExponentialBackOff'; diff --git a/packages/shared/src/noop.ts b/packages/shared/src/utils/noop.ts similarity index 100% rename from packages/shared/src/noop.ts rename to packages/shared/src/utils/noop.ts diff --git a/packages/shared/src/workerTimers/createWorkerTimers.ts b/packages/shared/src/workerTimers/createWorkerTimers.ts index 7c5a1c9d65..91c32ba816 100644 --- a/packages/shared/src/workerTimers/createWorkerTimers.ts +++ b/packages/shared/src/workerTimers/createWorkerTimers.ts @@ -1,4 +1,4 @@ -import { noop } from '../noop'; +import { noop } from '../utils/noop'; import type { WorkerClearTimeout, WorkerSetTimeout, From 0aa5f686fff90110fdc3e87c82c480efbc6b7f6a Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 13:40:25 +0200 Subject: [PATCH 24/53] chore(shared): Re-organize hooks folder --- packages/shared/src/{hooks => react}/clerk-swr.ts | 0 packages/shared/src/{hooks => react}/contexts.tsx | 4 ++-- .../src/{ => react}/hooks/createContextAndHook.ts | 0 packages/shared/src/react/hooks/index.ts | 5 +++++ .../src/{ => react}/hooks/useOrganization.tsx | 8 ++++---- .../src/{ => react}/hooks/useOrganizationList.tsx | 6 +++--- .../src/{ => react}/hooks/useOrganizations.tsx | 4 ++-- .../src/{ => react}/hooks/usePagesOrInfinite.ts | 6 +++--- .../src/{ => react}/hooks/useSafeLayoutEffect.tsx | 0 packages/shared/src/react/index.ts | 13 +++++++++++++ packages/shared/src/{hooks => react}/types.ts | 0 11 files changed, 32 insertions(+), 14 deletions(-) rename packages/shared/src/{hooks => react}/clerk-swr.ts (100%) rename packages/shared/src/{hooks => react}/contexts.tsx (95%) rename packages/shared/src/{ => react}/hooks/createContextAndHook.ts (100%) create mode 100644 packages/shared/src/react/hooks/index.ts rename packages/shared/src/{ => react}/hooks/useOrganization.tsx (98%) rename packages/shared/src/{ => react}/hooks/useOrganizationList.tsx (97%) rename packages/shared/src/{ => react}/hooks/useOrganizations.tsx (95%) rename packages/shared/src/{ => react}/hooks/usePagesOrInfinite.ts (97%) rename packages/shared/src/{ => react}/hooks/useSafeLayoutEffect.tsx (100%) create mode 100644 packages/shared/src/react/index.ts rename packages/shared/src/{hooks => react}/types.ts (100%) diff --git a/packages/shared/src/hooks/clerk-swr.ts b/packages/shared/src/react/clerk-swr.ts similarity index 100% rename from packages/shared/src/hooks/clerk-swr.ts rename to packages/shared/src/react/clerk-swr.ts diff --git a/packages/shared/src/hooks/contexts.tsx b/packages/shared/src/react/contexts.tsx similarity index 95% rename from packages/shared/src/hooks/contexts.tsx rename to packages/shared/src/react/contexts.tsx index d70c53f3e0..863104a0fb 100644 --- a/packages/shared/src/hooks/contexts.tsx +++ b/packages/shared/src/react/contexts.tsx @@ -12,9 +12,9 @@ import type { import type { PropsWithChildren } from 'react'; import React from 'react'; -import { deprecated } from '../utils'; +import { deprecated } from '../deprecated'; import { SWRConfig } from './clerk-swr'; -import { createContextAndHook } from './createContextAndHook'; +import { createContextAndHook } from './hooks/createContextAndHook'; const [ClerkInstanceContext, useClerkInstanceContext] = createContextAndHook('ClerkInstanceContext'); const [UserContext, useUserContext] = createContextAndHook('UserContext'); diff --git a/packages/shared/src/hooks/createContextAndHook.ts b/packages/shared/src/react/hooks/createContextAndHook.ts similarity index 100% rename from packages/shared/src/hooks/createContextAndHook.ts rename to packages/shared/src/react/hooks/createContextAndHook.ts diff --git a/packages/shared/src/react/hooks/index.ts b/packages/shared/src/react/hooks/index.ts new file mode 100644 index 0000000000..a250361a7f --- /dev/null +++ b/packages/shared/src/react/hooks/index.ts @@ -0,0 +1,5 @@ +export { assertContextExists, createContextAndHook } from './createContextAndHook'; +export { useOrganization } from './useOrganization'; +export { useOrganizationList } from './useOrganizationList'; +export { useOrganizations } from './useOrganizations'; +export { useSafeLayoutEffect } from './useSafeLayoutEffect'; diff --git a/packages/shared/src/hooks/useOrganization.tsx b/packages/shared/src/react/hooks/useOrganization.tsx similarity index 98% rename from packages/shared/src/hooks/useOrganization.tsx rename to packages/shared/src/react/hooks/useOrganization.tsx index 3c27babf3c..1e0fe64340 100644 --- a/packages/shared/src/hooks/useOrganization.tsx +++ b/packages/shared/src/react/hooks/useOrganization.tsx @@ -14,10 +14,10 @@ import type { import type { ClerkPaginatedResponse } from '@clerk/types'; import type { GetMembersParams } from '@clerk/types'; -import { deprecated } from '../utils'; -import { useSWR } from './clerk-swr'; -import { useClerkInstanceContext, useOrganizationContext, useSessionContext } from './contexts'; -import type { PaginatedResources, PaginatedResourcesWithDefault } from './types'; +import { deprecated } from '../../deprecated'; +import { useSWR } from '../clerk-swr'; +import { useClerkInstanceContext, useOrganizationContext, useSessionContext } from '../contexts'; +import type { PaginatedResources, PaginatedResourcesWithDefault } from '../types'; import { usePagesOrInfinite, useWithSafeValues } from './usePagesOrInfinite'; type UseOrganizationParams = { diff --git a/packages/shared/src/hooks/useOrganizationList.tsx b/packages/shared/src/react/hooks/useOrganizationList.tsx similarity index 97% rename from packages/shared/src/hooks/useOrganizationList.tsx rename to packages/shared/src/react/hooks/useOrganizationList.tsx index e536b57b8a..beae119aa1 100644 --- a/packages/shared/src/hooks/useOrganizationList.tsx +++ b/packages/shared/src/react/hooks/useOrganizationList.tsx @@ -11,9 +11,9 @@ import type { UserOrganizationInvitationResource, } from '@clerk/types'; -import { deprecatedObjectProperty } from '../utils'; -import { useClerkInstanceContext, useUserContext } from './contexts'; -import type { PaginatedResources, PaginatedResourcesWithDefault } from './types'; +import { deprecatedObjectProperty } from '../../deprecated'; +import { useClerkInstanceContext, useUserContext } from '../contexts'; +import type { PaginatedResources, PaginatedResourcesWithDefault } from '../types'; import { usePagesOrInfinite, useWithSafeValues } from './usePagesOrInfinite'; type UseOrganizationListParams = { diff --git a/packages/shared/src/hooks/useOrganizations.tsx b/packages/shared/src/react/hooks/useOrganizations.tsx similarity index 95% rename from packages/shared/src/hooks/useOrganizations.tsx rename to packages/shared/src/react/hooks/useOrganizations.tsx index 41439235b9..60bfe8ca77 100644 --- a/packages/shared/src/hooks/useOrganizations.tsx +++ b/packages/shared/src/react/hooks/useOrganizations.tsx @@ -1,7 +1,7 @@ import type { CreateOrganizationParams, OrganizationMembershipResource, OrganizationResource } from '@clerk/types'; -import { deprecated } from '../utils'; -import { useClerkInstanceContext } from './contexts'; +import { deprecated } from '../../deprecated'; +import { useClerkInstanceContext } from '../contexts'; type UseOrganizationsReturn = | { diff --git a/packages/shared/src/hooks/usePagesOrInfinite.ts b/packages/shared/src/react/hooks/usePagesOrInfinite.ts similarity index 97% rename from packages/shared/src/hooks/usePagesOrInfinite.ts rename to packages/shared/src/react/hooks/usePagesOrInfinite.ts index 1af2afa023..be8e12f281 100644 --- a/packages/shared/src/hooks/usePagesOrInfinite.ts +++ b/packages/shared/src/react/hooks/usePagesOrInfinite.ts @@ -2,9 +2,9 @@ import { useCallback, useMemo, useRef, useState } from 'react'; -import { useSWR, useSWRInfinite } from './clerk-swr'; -import type { ValueOrSetter } from './types'; -import type { PaginatedResources } from './types'; +import { useSWR, useSWRInfinite } from '../clerk-swr'; +import type { ValueOrSetter } from '../types'; +import type { PaginatedResources } from '../types'; function getDifferentKeys(obj1: Record, obj2: Record): Record { const keysSet = new Set(Object.keys(obj2)); diff --git a/packages/shared/src/hooks/useSafeLayoutEffect.tsx b/packages/shared/src/react/hooks/useSafeLayoutEffect.tsx similarity index 100% rename from packages/shared/src/hooks/useSafeLayoutEffect.tsx rename to packages/shared/src/react/hooks/useSafeLayoutEffect.tsx diff --git a/packages/shared/src/react/index.ts b/packages/shared/src/react/index.ts new file mode 100644 index 0000000000..e22d53ca69 --- /dev/null +++ b/packages/shared/src/react/index.ts @@ -0,0 +1,13 @@ +export { + ClerkInstanceContext, + ClientContext, + OrganizationContext, + OrganizationProvider, + SessionContext, + useClerkInstanceContext, + useClientContext, + useOrganizationContext, + UserContext, + useSessionContext, + useUserContext, +} from './contexts'; diff --git a/packages/shared/src/hooks/types.ts b/packages/shared/src/react/types.ts similarity index 100% rename from packages/shared/src/hooks/types.ts rename to packages/shared/src/react/types.ts From 54a52a65ece0548d20ec6bc065aff148c7ef1557 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 14:09:04 +0200 Subject: [PATCH 25/53] chore(shared): Correct tsup output + exports map --- packages/shared/package.json | 37 ++++++++++++++++++++++++++++------ packages/shared/tsup.config.ts | 20 ++---------------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/packages/shared/package.json b/packages/shared/package.json index e83f3ae85f..ddd362c941 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -2,18 +2,43 @@ "name": "@clerk/shared", "version": "0.24.3", "description": "Internal package utils used by the Clerk SDKs", - "types": "./dist/types/index.d.ts", - "main": "./dist/cjs/index.js", - "module": "./dist/esm/index.js", + "types": "./dist/index.d.ts", + "main": "./dist/index.js", + "module": "./dist/index.mjs", "sideEffects": false, "files": [ "dist" ], "exports": { ".": { - "types": "./dist/types/index.d.ts", - "import": "./dist/esm/index.js", - "require": "./dist/cjs/index.js" + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, + "./*": { + "import": { + "types": "./dist/*.d.mts", + "default": "./dist/*.mjs" + }, + "require": { + "types": "./dist/*.d.ts", + "default": "./dist/*.js" + } + }, + "./dist/*": { + "import": { + "types": "./dist/*.d.mts", + "default": "./dist/*.mjs" + }, + "require": { + "types": "./dist/*.d.ts", + "default": "./dist/*.js" + } } }, "scripts": { diff --git a/packages/shared/tsup.config.ts b/packages/shared/tsup.config.ts index 35d574b18e..11ee9555a7 100644 --- a/packages/shared/tsup.config.ts +++ b/packages/shared/tsup.config.ts @@ -1,23 +1,20 @@ import type { Plugin } from 'esbuild'; import { transform } from 'esbuild'; import { readFile } from 'fs/promises'; -import type { Options } from 'tsup'; import { defineConfig } from 'tsup'; -import { runAfterLast } from '../../scripts/utils'; import { name, version } from './package.json'; export default defineConfig(overrideOptions => { const isWatch = !!overrideOptions.watch; - const shouldPublish = !!overrideOptions.env?.publish; - const common: Options = { + return { entry: ['./src/**/*.{ts,tsx}', '!./src/**/*.test.{ts,tsx}'], + format: ['cjs', 'esm'], bundle: false, clean: true, minify: false, sourcemap: true, - legacyOutput: true, dts: true, external: ['react', 'react-dom'], esbuildPlugins: [WebWorkerMinifyPlugin as any], @@ -27,19 +24,6 @@ export default defineConfig(overrideOptions => { __DEV__: `${isWatch}`, }, }; - - const esm: Options = { - ...common, - format: 'esm', - }; - - const cjs: Options = { - ...common, - format: 'cjs', - outDir: './dist/cjs', - }; - - return runAfterLast([shouldPublish && 'npm run publish:local'])(esm, cjs); }); // Read transform and minify any files ending in .worker.ts From 85489c066438e87a9ee4b182ee63657565783cdf Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 14:09:21 +0200 Subject: [PATCH 26/53] chore(shared): Add minimal README --- packages/shared/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/shared/README.md diff --git a/packages/shared/README.md b/packages/shared/README.md new file mode 100644 index 0000000000..e0dddaca1a --- /dev/null +++ b/packages/shared/README.md @@ -0,0 +1,3 @@ +# @clerk/shared + +Utilities used in `@clerk` packages From 5506ab8266a013e3e723620903a4bd0081d7a2d8 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 15:33:27 +0200 Subject: [PATCH 27/53] fix(backend): Update imports --- packages/backend/src/api/endpoints/OrganizationApi.ts | 2 +- packages/backend/src/index.ts | 2 +- packages/backend/src/tokens/authObjects.ts | 2 +- packages/backend/src/tokens/jwt/verifyJwt.ts | 2 +- packages/backend/src/util/shared.ts | 5 ++--- packages/backend/tsconfig.json | 3 ++- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/api/endpoints/OrganizationApi.ts b/packages/backend/src/api/endpoints/OrganizationApi.ts index e8427747f4..7ac2435fcb 100644 --- a/packages/backend/src/api/endpoints/OrganizationApi.ts +++ b/packages/backend/src/api/endpoints/OrganizationApi.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import runtime from '../../runtime'; import { joinPaths } from '../../util/path'; diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 9879546c9e..0d1a552ca2 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -1,4 +1,4 @@ -import { deprecatedObjectProperty } from '@clerk/shared'; +import { deprecatedObjectProperty } from '@clerk/shared/deprecated'; import type { CreateBackendApiOptions } from './api'; import { createBackendApiClient } from './api'; diff --git a/packages/backend/src/tokens/authObjects.ts b/packages/backend/src/tokens/authObjects.ts index bd2e5bcb72..ccecdd637b 100644 --- a/packages/backend/src/tokens/authObjects.ts +++ b/packages/backend/src/tokens/authObjects.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { ActClaim, JwtPayload, ServerGetToken, ServerGetTokenOptions } from '@clerk/types'; import type { Organization, Session, User } from '../api'; diff --git a/packages/backend/src/tokens/jwt/verifyJwt.ts b/packages/backend/src/tokens/jwt/verifyJwt.ts index de0c64067f..84098b3a8e 100644 --- a/packages/backend/src/tokens/jwt/verifyJwt.ts +++ b/packages/backend/src/tokens/jwt/verifyJwt.ts @@ -1,4 +1,4 @@ -import { deprecatedObjectProperty } from '@clerk/shared'; +import { deprecatedObjectProperty } from '@clerk/shared/deprecated'; import type { Jwt, JwtPayload } from '@clerk/types'; // DO NOT CHANGE: Runtime needs to be imported as a default export so that we can stub its dependencies with Sinon.js diff --git a/packages/backend/src/util/shared.ts b/packages/backend/src/util/shared.ts index de2bd9a6ae..1b4d09e38a 100644 --- a/packages/backend/src/util/shared.ts +++ b/packages/backend/src/util/shared.ts @@ -6,11 +6,10 @@ export { isDevelopmentFromApiKey, isProductionFromApiKey, parsePublishableKey, - deprecated, - deprecatedProperty, } from '@clerk/shared'; +export { deprecated, deprecatedProperty } from '@clerk/shared/deprecated'; -import { buildErrorThrower } from '@clerk/shared'; +import { buildErrorThrower } from '@clerk/shared/error'; // TODO: replace packageName with `${PACKAGE_NAME}@${PACKAGE_VERSION}` from tsup.config.ts export const errorThrower = buildErrorThrower({ packageName: '@clerk/backend' }); diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index 94d7f5aae5..e41e9a0895 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -2,12 +2,13 @@ "compilerOptions": { "allowSyntheticDefaultImports": true, "baseUrl": ".", + "rootDir": "src", "declaration": true, "declarationMap": false, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "importHelpers": true, - "moduleResolution": "node", + "moduleResolution": "NodeNext", "noImplicitReturns": true, "noUnusedLocals": false, "noUnusedParameters": true, From 7fd38a3d48b5f8197bb75e8faca1c7cdb35cbeef Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 15:34:06 +0200 Subject: [PATCH 28/53] chore(shared): Put error into one file + add react & react/hooks subpath --- packages/shared/package.json | 23 ++-- .../error.test.ts} | 4 +- .../shared/src/{error/Error.ts => error.ts} | 102 +++++++++++++++++- packages/shared/src/error/checks.ts | 16 --- packages/shared/src/error/index.ts | 3 - packages/shared/src/error/thrower.ts | 81 -------------- packages/shared/src/index.ts | 5 +- 7 files changed, 121 insertions(+), 113 deletions(-) rename packages/shared/src/{error/__tests__/thrower.test.ts => __tests__/error.test.ts} (93%) rename packages/shared/src/{error/Error.ts => error.ts} (57%) delete mode 100644 packages/shared/src/error/checks.ts delete mode 100644 packages/shared/src/error/index.ts delete mode 100644 packages/shared/src/error/thrower.ts diff --git a/packages/shared/package.json b/packages/shared/package.json index ddd362c941..e99306917a 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -2,9 +2,6 @@ "name": "@clerk/shared", "version": "0.24.3", "description": "Internal package utils used by the Clerk SDKs", - "types": "./dist/index.d.ts", - "main": "./dist/index.js", - "module": "./dist/index.mjs", "sideEffects": false, "files": [ "dist" @@ -30,14 +27,24 @@ "default": "./dist/*.js" } }, - "./dist/*": { + "./react": { "import": { - "types": "./dist/*.d.mts", - "default": "./dist/*.mjs" + "types": "./dist/react/index.d.mts", + "default": "./dist/react/index.mjs" }, "require": { - "types": "./dist/*.d.ts", - "default": "./dist/*.js" + "types": "./dist/react/index.d.ts", + "default": "./dist/react/index.js" + } + }, + "./react/hooks": { + "import": { + "types": "./dist/react/hooks/index.d.mts", + "default": "./dist/react/hooks/index.mjs" + }, + "require": { + "types": "./dist/react/hooks/index.d.ts", + "default": "./dist/react/hooks/index.js" } } }, diff --git a/packages/shared/src/error/__tests__/thrower.test.ts b/packages/shared/src/__tests__/error.test.ts similarity index 93% rename from packages/shared/src/error/__tests__/thrower.test.ts rename to packages/shared/src/__tests__/error.test.ts index 73c62d7bfd..6d668c99f2 100644 --- a/packages/shared/src/error/__tests__/thrower.test.ts +++ b/packages/shared/src/__tests__/error.test.ts @@ -1,5 +1,5 @@ -import type { ErrorThrowerOptions } from '../thrower'; -import { buildErrorThrower } from '../thrower'; +import type { ErrorThrowerOptions } from '../error'; +import { buildErrorThrower } from '../error'; describe('ErrorThrower', () => { const errorThrower = buildErrorThrower({ packageName: '@clerk/test-package' }); diff --git a/packages/shared/src/error/Error.ts b/packages/shared/src/error.ts similarity index 57% rename from packages/shared/src/error/Error.ts rename to packages/shared/src/error.ts index 4dcdd1ada4..f21d3e4a21 100644 --- a/packages/shared/src/error/Error.ts +++ b/packages/shared/src/error.ts @@ -1,6 +1,23 @@ import type { ClerkAPIError, ClerkAPIErrorJSON } from '@clerk/types'; -import { deprecated } from '../deprecated'; +import { deprecated } from './deprecated'; + +export function isUnauthorizedError(e: any): boolean { + const status = e?.status; + const code = e?.errors?.[0]?.code; + return code === 'authentication_invalid' && status === 401; +} + +export function is4xxError(e: any): boolean { + const status = e?.status; + return !!status && status >= 400 && status < 500; +} + +export function isNetworkError(e: any): boolean { + // TODO: revise during error handling epic + const message = (`${e.message}${e.name}` || '').toLowerCase().replace(/\s+/g, ''); + return message.includes('networkerror'); +} interface ClerkAPIResponseOptions { data: ClerkAPIErrorJSON[]; @@ -179,6 +196,7 @@ const _MagicLinkErrorCode = { Expired: 'expired', Failed: 'failed', }; + /** * @deprecated Use `EmailLinkErrorCode` instead. */ @@ -193,3 +211,85 @@ export const EmailLinkErrorCode = { Expired: 'expired', Failed: 'failed', }; + +const DefaultMessages = Object.freeze({ + InvalidFrontendApiErrorMessage: `The frontendApi passed to Clerk is invalid. You can get your Frontend API key at https://dashboard.clerk.com/last-active?path=api-keys. (key={{key}})`, + InvalidProxyUrlErrorMessage: `The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})`, + InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid. You can get your Publishable key at https://dashboard.clerk.com/last-active?path=api-keys. (key={{key}})`, + MissingPublishableKeyErrorMessage: `Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.`, +}); + +type MessageKeys = keyof typeof DefaultMessages; + +type Messages = Record; + +type CustomMessages = Partial; + +export type ErrorThrowerOptions = { + packageName: string; + customMessages?: CustomMessages; +}; + +export interface ErrorThrower { + setPackageName(options: ErrorThrowerOptions): ErrorThrower; + setMessages(options: ErrorThrowerOptions): ErrorThrower; + throwInvalidPublishableKeyError(params: { key?: string }): never; + throwInvalidFrontendApiError(params: { key?: string }): never; + throwInvalidProxyUrl(params: { url?: string }): never; + throwMissingPublishableKeyError(): never; +} + +export function buildErrorThrower({ packageName, customMessages }: ErrorThrowerOptions): ErrorThrower { + let pkg = packageName; + + const messages = { + ...DefaultMessages, + ...customMessages, + }; + + function buildMessage(rawMessage: string, replacements?: Record) { + if (!replacements) { + return `${pkg}: ${rawMessage}`; + } + + let msg = rawMessage; + const matches = rawMessage.matchAll(/{{([a-zA-Z0-9-_]+)}}/g); + + for (const match of matches) { + const replacement = (replacements[match[1]] || '').toString(); + msg = msg.replace(`{{${match[1]}}}`, replacement); + } + + return `${pkg}: ${msg}`; + } + + return { + setPackageName({ packageName }: ErrorThrowerOptions): ErrorThrower { + if (typeof packageName === 'string') { + pkg = packageName; + } + return this; + }, + + setMessages({ customMessages }: ErrorThrowerOptions): ErrorThrower { + Object.assign(messages, customMessages || {}); + return this; + }, + + throwInvalidPublishableKeyError(params: { key?: string }): never { + throw new Error(buildMessage(messages.InvalidPublishableKeyErrorMessage, params)); + }, + + throwInvalidFrontendApiError(params: { key?: string }): never { + throw new Error(buildMessage(messages.InvalidFrontendApiErrorMessage, params)); + }, + + throwInvalidProxyUrl(params: { url?: string }): never { + throw new Error(buildMessage(messages.InvalidProxyUrlErrorMessage, params)); + }, + + throwMissingPublishableKeyError(): never { + throw new Error(buildMessage(messages.MissingPublishableKeyErrorMessage)); + }, + }; +} diff --git a/packages/shared/src/error/checks.ts b/packages/shared/src/error/checks.ts deleted file mode 100644 index 82a5f2e901..0000000000 --- a/packages/shared/src/error/checks.ts +++ /dev/null @@ -1,16 +0,0 @@ -export function isUnauthorizedError(e: any): boolean { - const status = e?.status; - const code = e?.errors?.[0]?.code; - return code === 'authentication_invalid' && status === 401; -} - -export function is4xxError(e: any): boolean { - const status = e?.status; - return !!status && status >= 400 && status < 500; -} - -export function isNetworkError(e: any): boolean { - // TODO: revise during error handling epic - const message = (`${e.message}${e.name}` || '').toLowerCase().replace(/\s+/g, ''); - return message.includes('networkerror'); -} diff --git a/packages/shared/src/error/index.ts b/packages/shared/src/error/index.ts deleted file mode 100644 index 54c1fbe792..0000000000 --- a/packages/shared/src/error/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './checks'; -export * from './Error'; -export * from './thrower'; diff --git a/packages/shared/src/error/thrower.ts b/packages/shared/src/error/thrower.ts deleted file mode 100644 index 12f91b3419..0000000000 --- a/packages/shared/src/error/thrower.ts +++ /dev/null @@ -1,81 +0,0 @@ -const DefaultMessages = Object.freeze({ - InvalidFrontendApiErrorMessage: `The frontendApi passed to Clerk is invalid. You can get your Frontend API key at https://dashboard.clerk.com/last-active?path=api-keys. (key={{key}})`, - InvalidProxyUrlErrorMessage: `The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})`, - InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid. You can get your Publishable key at https://dashboard.clerk.com/last-active?path=api-keys. (key={{key}})`, - MissingPublishableKeyErrorMessage: `Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.`, -}); - -type MessageKeys = keyof typeof DefaultMessages; - -type Messages = Record; - -type CustomMessages = Partial; - -export type ErrorThrowerOptions = { - packageName: string; - customMessages?: CustomMessages; -}; - -export interface ErrorThrower { - setPackageName(options: ErrorThrowerOptions): ErrorThrower; - setMessages(options: ErrorThrowerOptions): ErrorThrower; - throwInvalidPublishableKeyError(params: { key?: string }): never; - throwInvalidFrontendApiError(params: { key?: string }): never; - throwInvalidProxyUrl(params: { url?: string }): never; - throwMissingPublishableKeyError(): never; -} - -export function buildErrorThrower({ packageName, customMessages }: ErrorThrowerOptions): ErrorThrower { - let pkg = packageName; - - const messages = { - ...DefaultMessages, - ...customMessages, - }; - - function buildMessage(rawMessage: string, replacements?: Record) { - if (!replacements) { - return `${pkg}: ${rawMessage}`; - } - - let msg = rawMessage; - const matches = rawMessage.matchAll(/{{([a-zA-Z0-9-_]+)}}/g); - - for (const match of matches) { - const replacement = (replacements[match[1]] || '').toString(); - msg = msg.replace(`{{${match[1]}}}`, replacement); - } - - return `${pkg}: ${msg}`; - } - - return { - setPackageName({ packageName }: ErrorThrowerOptions): ErrorThrower { - if (typeof packageName === 'string') { - pkg = packageName; - } - return this; - }, - - setMessages({ customMessages }: ErrorThrowerOptions): ErrorThrower { - Object.assign(messages, customMessages || {}); - return this; - }, - - throwInvalidPublishableKeyError(params: { key?: string }): never { - throw new Error(buildMessage(messages.InvalidPublishableKeyErrorMessage, params)); - }, - - throwInvalidFrontendApiError(params: { key?: string }): never { - throw new Error(buildMessage(messages.InvalidFrontendApiErrorMessage, params)); - }, - - throwInvalidProxyUrl(params: { url?: string }): never { - throw new Error(buildMessage(messages.InvalidProxyUrlErrorMessage, params)); - }, - - throwMissingPublishableKeyError(): never { - throw new Error(buildMessage(messages.MissingPublishableKeyErrorMessage)); - }, - }; -} diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 24d1f3a775..8e9fbb809e 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -3,18 +3,19 @@ * - globs.ts * * The following folders are also not exported on purpose: - * - error * - react - * - utils * * People should always use @clerk/shared/ instead */ +export * from './utils'; + export { createWorkerTimers } from './workerTimers'; export * from './browser'; export * from './color'; export * from './date'; export * from './deprecated'; +export * from './error'; export * from './file'; export { isomorphicAtob } from './isomorphicAtob'; export * from './keys'; From feb461df1dd3fe1ed77506c336b87ffe918641e8 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 15:51:50 +0200 Subject: [PATCH 29/53] fix(clerk-js): Update imports --- packages/clerk-js/src/core/resources/Base.ts | 2 +- packages/clerk-js/src/core/resources/DisplayConfig.ts | 2 +- packages/clerk-js/src/core/resources/EmailAddress.ts | 3 ++- packages/clerk-js/src/core/resources/Error.ts | 4 ++-- packages/clerk-js/src/core/resources/Organization.ts | 2 +- .../clerk-js/src/core/resources/OrganizationMembership.ts | 2 +- packages/clerk-js/src/core/resources/PublicUserData.ts | 2 +- packages/clerk-js/src/core/resources/Session.ts | 4 +++- packages/clerk-js/src/core/resources/User.ts | 3 +-- packages/clerk-js/src/core/resources/UserData.ts | 2 +- packages/clerk-js/src/core/resources/Web3Wallet.ts | 2 +- .../src/core/services/authentication/SessionCookieService.ts | 4 +--- packages/clerk-js/src/ui/Components.tsx | 3 ++- packages/clerk-js/src/ui/common/EmailLinkVerify.tsx | 2 +- .../clerk-js/src/ui/common/__tests__/verification.test.ts | 2 +- packages/clerk-js/src/ui/common/constants.ts | 2 +- .../ui/components/OrganizationProfile/InviteMembersForm.tsx | 2 +- .../src/ui/components/UserButton/useMultisessionActions.tsx | 4 +++- packages/clerk-js/src/ui/contexts/CoreClerkContext.tsx | 2 +- packages/clerk-js/src/ui/contexts/CoreClientContext.tsx | 3 ++- packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx | 3 ++- packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx | 3 ++- packages/clerk-js/src/ui/contexts/CoreUserContext.tsx | 3 ++- packages/clerk-js/src/ui/customizables/AppearanceContext.tsx | 2 +- packages/clerk-js/src/ui/elements/Form.tsx | 2 +- packages/clerk-js/src/ui/elements/Menu.tsx | 2 +- packages/clerk-js/src/ui/elements/Modal.tsx | 2 +- packages/clerk-js/src/ui/elements/Navbar.tsx | 2 +- packages/clerk-js/src/ui/elements/Select.tsx | 2 +- packages/clerk-js/src/ui/elements/Tabs.tsx | 2 +- packages/clerk-js/src/ui/elements/TimerButton.tsx | 2 +- .../clerk-js/src/ui/elements/contexts/CardStateContext.tsx | 2 +- .../clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx | 2 +- packages/clerk-js/src/ui/localization/makeLocalizable.tsx | 2 +- packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx | 2 +- packages/clerk-js/src/utils/captcha.ts | 2 +- packages/clerk-js/src/utils/cookies/client.ts | 2 +- packages/clerk-js/src/utils/cookies/client_uat.ts | 2 +- packages/clerk-js/src/utils/cookies/devBrowser.ts | 2 +- packages/clerk-js/src/utils/cookies/initted.ts | 2 +- packages/clerk-js/src/utils/cookies/session.ts | 2 +- packages/clerk-js/src/utils/errorThrower.ts | 2 +- packages/clerk-js/src/utils/image.ts | 2 +- packages/clerk-js/src/utils/jwt.ts | 2 +- packages/clerk-js/src/utils/pageLifecycle.ts | 2 +- packages/clerk-js/src/utils/url.ts | 3 ++- packages/clerk-js/tsconfig.json | 2 +- 47 files changed, 59 insertions(+), 51 deletions(-) diff --git a/packages/clerk-js/src/core/resources/Base.ts b/packages/clerk-js/src/core/resources/Base.ts index 04a5112a9d..7f032cd8c4 100644 --- a/packages/clerk-js/src/core/resources/Base.ts +++ b/packages/clerk-js/src/core/resources/Base.ts @@ -1,4 +1,4 @@ -import { isValidBrowserOnline } from '@clerk/shared'; +import { isValidBrowserOnline } from '@clerk/shared/browser'; import type { ClerkAPIErrorJSON, ClerkResourceJSON, ClerkResourceReloadParams, DeletedObjectJSON } from '@clerk/types'; import { clerkMissingFapiClientInResources } from '../errors'; diff --git a/packages/clerk-js/src/core/resources/DisplayConfig.ts b/packages/clerk-js/src/core/resources/DisplayConfig.ts index ee83cca78a..5a2313b69c 100644 --- a/packages/clerk-js/src/core/resources/DisplayConfig.ts +++ b/packages/clerk-js/src/core/resources/DisplayConfig.ts @@ -1,4 +1,4 @@ -import { deprecatedProperty } from '@clerk/shared'; +import { deprecatedProperty } from '@clerk/shared/deprecated'; import type { DisplayConfigJSON, DisplayConfigResource, DisplayThemeJSON, PreferredSignInStrategy } from '@clerk/types'; import { BaseResource } from './internal'; diff --git a/packages/clerk-js/src/core/resources/EmailAddress.ts b/packages/clerk-js/src/core/resources/EmailAddress.ts index 340fb620ee..2dbf00cd2a 100644 --- a/packages/clerk-js/src/core/resources/EmailAddress.ts +++ b/packages/clerk-js/src/core/resources/EmailAddress.ts @@ -1,4 +1,5 @@ -import { deprecated, Poller } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; +import { Poller } from '@clerk/shared/poller'; import type { AttemptEmailAddressVerificationParams, CreateEmailLinkFlowReturn, diff --git a/packages/clerk-js/src/core/resources/Error.ts b/packages/clerk-js/src/core/resources/Error.ts index b659a38014..a8baf8742a 100644 --- a/packages/clerk-js/src/core/resources/Error.ts +++ b/packages/clerk-js/src/core/resources/Error.ts @@ -13,5 +13,5 @@ export { MagicLinkErrorCode, parseError, parseErrors, -} from '@clerk/shared'; -export type { MetamaskError } from '@clerk/shared'; +} from '@clerk/shared/error'; +export type { MetamaskError } from '@clerk/shared/error'; diff --git a/packages/clerk-js/src/core/resources/Organization.ts b/packages/clerk-js/src/core/resources/Organization.ts index 5f327a1ee8..e285635925 100644 --- a/packages/clerk-js/src/core/resources/Organization.ts +++ b/packages/clerk-js/src/core/resources/Organization.ts @@ -1,4 +1,4 @@ -import { deprecated, deprecatedProperty } from '@clerk/shared'; +import { deprecated, deprecatedProperty } from '@clerk/shared/deprecated'; import type { AddMemberParams, ClerkPaginatedResponse, diff --git a/packages/clerk-js/src/core/resources/OrganizationMembership.ts b/packages/clerk-js/src/core/resources/OrganizationMembership.ts index 9686df2f2b..c3176725e5 100644 --- a/packages/clerk-js/src/core/resources/OrganizationMembership.ts +++ b/packages/clerk-js/src/core/resources/OrganizationMembership.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { ClerkPaginatedResponse, ClerkResourceReloadParams, diff --git a/packages/clerk-js/src/core/resources/PublicUserData.ts b/packages/clerk-js/src/core/resources/PublicUserData.ts index a3de715ab7..7fd6e93de6 100644 --- a/packages/clerk-js/src/core/resources/PublicUserData.ts +++ b/packages/clerk-js/src/core/resources/PublicUserData.ts @@ -1,4 +1,4 @@ -import { deprecatedProperty } from '@clerk/shared'; +import { deprecatedProperty } from '@clerk/shared/deprecated'; import type { PublicUserData as IPublicUserData } from '@clerk/types'; import type { PublicUserDataJSON } from '@clerk/types'; diff --git a/packages/clerk-js/src/core/resources/Session.ts b/packages/clerk-js/src/core/resources/Session.ts index c8acaac84e..b719060194 100644 --- a/packages/clerk-js/src/core/resources/Session.ts +++ b/packages/clerk-js/src/core/resources/Session.ts @@ -1,5 +1,5 @@ -import { is4xxError } from '@clerk/shared'; import { runWithExponentialBackOff } from '@clerk/shared'; +import { is4xxError } from '@clerk/shared/error'; import type { ActJWTClaim, GetToken, @@ -70,6 +70,8 @@ export class Session extends BaseResource implements SessionResource { return SessionTokenCache.clear(); }; + // TODO: Fix this eslint error + // eslint-disable-next-line @typescript-eslint/require-await getToken: GetToken = async (options?: GetTokenOptions): Promise => { return runWithExponentialBackOff(() => this._getToken(options), { shouldRetry: (error: unknown, currentIteration: number) => !is4xxError(error) && currentIteration < 4, diff --git a/packages/clerk-js/src/core/resources/User.ts b/packages/clerk-js/src/core/resources/User.ts index 31898f8b75..3757a5486d 100644 --- a/packages/clerk-js/src/core/resources/User.ts +++ b/packages/clerk-js/src/core/resources/User.ts @@ -1,5 +1,4 @@ -import { deprecated } from '@clerk/shared'; -import { deprecatedProperty } from '@clerk/shared'; +import { deprecated, deprecatedProperty } from '@clerk/shared/deprecated'; import type { BackupCodeJSON, BackupCodeResource, diff --git a/packages/clerk-js/src/core/resources/UserData.ts b/packages/clerk-js/src/core/resources/UserData.ts index f19e284d24..00dfa60e2d 100644 --- a/packages/clerk-js/src/core/resources/UserData.ts +++ b/packages/clerk-js/src/core/resources/UserData.ts @@ -1,4 +1,4 @@ -import { deprecatedProperty } from '@clerk/shared'; +import { deprecatedProperty } from '@clerk/shared/deprecated'; import type { UserData as IUserData } from '@clerk/types'; import type { UserDataJSON } from '@clerk/types'; diff --git a/packages/clerk-js/src/core/resources/Web3Wallet.ts b/packages/clerk-js/src/core/resources/Web3Wallet.ts index 3359495db5..3386a077b9 100644 --- a/packages/clerk-js/src/core/resources/Web3Wallet.ts +++ b/packages/clerk-js/src/core/resources/Web3Wallet.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { AttemptWeb3WalletVerificationParams, PrepareWeb3WalletVerificationParams, diff --git a/packages/clerk-js/src/core/services/authentication/SessionCookieService.ts b/packages/clerk-js/src/core/services/authentication/SessionCookieService.ts index 9fdde1428d..ad75670e4b 100644 --- a/packages/clerk-js/src/core/services/authentication/SessionCookieService.ts +++ b/packages/clerk-js/src/core/services/authentication/SessionCookieService.ts @@ -1,6 +1,4 @@ -import { isClerkAPIResponseError } from '@clerk/shared'; -import { isNetworkError } from '@clerk/shared'; -import { is4xxError } from '@clerk/shared'; +import { is4xxError, isClerkAPIResponseError, isNetworkError } from '@clerk/shared/error'; import type { Clerk, EnvironmentResource, SessionResource, TokenResource } from '@clerk/types'; import type { CookieHandler } from '../../../utils'; diff --git a/packages/clerk-js/src/ui/Components.tsx b/packages/clerk-js/src/ui/Components.tsx index c6df252b7a..7d9a1f966a 100644 --- a/packages/clerk-js/src/ui/Components.tsx +++ b/packages/clerk-js/src/ui/Components.tsx @@ -1,4 +1,5 @@ -import { createDeferredPromise, useSafeLayoutEffect } from '@clerk/shared'; +import { createDeferredPromise } from '@clerk/shared'; +import { useSafeLayoutEffect } from '@clerk/shared/react/hooks'; import type { Appearance, Clerk, diff --git a/packages/clerk-js/src/ui/common/EmailLinkVerify.tsx b/packages/clerk-js/src/ui/common/EmailLinkVerify.tsx index 188eee35a6..9c20e2ce05 100644 --- a/packages/clerk-js/src/ui/common/EmailLinkVerify.tsx +++ b/packages/clerk-js/src/ui/common/EmailLinkVerify.tsx @@ -1,4 +1,4 @@ -import { EmailLinkErrorCode, isEmailLinkError } from '@clerk/shared'; +import { EmailLinkErrorCode, isEmailLinkError } from '@clerk/shared/error'; import React from 'react'; import type { VerificationStatus } from '../../utils/getClerkQueryParam'; diff --git a/packages/clerk-js/src/ui/common/__tests__/verification.test.ts b/packages/clerk-js/src/ui/common/__tests__/verification.test.ts index 5f76b4e780..6cb7970a46 100644 --- a/packages/clerk-js/src/ui/common/__tests__/verification.test.ts +++ b/packages/clerk-js/src/ui/common/__tests__/verification.test.ts @@ -1,4 +1,4 @@ -import { ClerkAPIResponseError } from '@clerk/shared'; +import { ClerkAPIResponseError } from '@clerk/shared/error'; import { isVerificationExpiredError, VerificationErrorMessage, verificationErrorMessage } from '../verification'; diff --git a/packages/clerk-js/src/ui/common/constants.ts b/packages/clerk-js/src/ui/common/constants.ts index 6ed53f9888..a4e9d3165b 100644 --- a/packages/clerk-js/src/ui/common/constants.ts +++ b/packages/clerk-js/src/ui/common/constants.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { Attribute, Web3Provider } from '@clerk/types'; import type { LocalizationKey } from '../localization/localizationKeys'; diff --git a/packages/clerk-js/src/ui/components/OrganizationProfile/InviteMembersForm.tsx b/packages/clerk-js/src/ui/components/OrganizationProfile/InviteMembersForm.tsx index 035ee83edd..109f1d667e 100644 --- a/packages/clerk-js/src/ui/components/OrganizationProfile/InviteMembersForm.tsx +++ b/packages/clerk-js/src/ui/components/OrganizationProfile/InviteMembersForm.tsx @@ -1,4 +1,4 @@ -import { isClerkAPIResponseError } from '@clerk/shared'; +import { isClerkAPIResponseError } from '@clerk/shared/error'; import type { MembershipRole, OrganizationResource } from '@clerk/types'; import React from 'react'; diff --git a/packages/clerk-js/src/ui/components/UserButton/useMultisessionActions.tsx b/packages/clerk-js/src/ui/components/UserButton/useMultisessionActions.tsx index 696982a244..ab6430e2a0 100644 --- a/packages/clerk-js/src/ui/components/UserButton/useMultisessionActions.tsx +++ b/packages/clerk-js/src/ui/components/UserButton/useMultisessionActions.tsx @@ -1,4 +1,4 @@ -import { deprecatedObjectProperty } from '@clerk/shared'; +import { deprecatedObjectProperty } from '@clerk/shared/deprecated'; import type { ActiveSessionResource, UserButtonProps, UserResource } from '@clerk/types'; import { windowNavigate } from '../../../utils/windowNavigate'; @@ -64,6 +64,8 @@ export const useMultisessionActions = (opts: UseMultisessionActionsParams) => { return signOut(opts.navigateAfterSignOut); }; + // TODO: Fix this eslint error + // eslint-disable-next-line @typescript-eslint/require-await const handleSessionClicked = (session: ActiveSessionResource) => async () => { card.setLoading(); return setActive({ session, beforeEmit: opts.navigateAfterSwitchSession }).finally(() => { diff --git a/packages/clerk-js/src/ui/contexts/CoreClerkContext.tsx b/packages/clerk-js/src/ui/contexts/CoreClerkContext.tsx index 6e32523bc4..66b28dd85f 100644 --- a/packages/clerk-js/src/ui/contexts/CoreClerkContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreClerkContext.tsx @@ -1,3 +1,3 @@ -import { ClerkInstanceContext, useClerkInstanceContext } from '@clerk/shared'; +import { ClerkInstanceContext, useClerkInstanceContext } from '@clerk/shared/react'; export const [CoreClerkContext, useCoreClerk] = [ClerkInstanceContext, useClerkInstanceContext]; diff --git a/packages/clerk-js/src/ui/contexts/CoreClientContext.tsx b/packages/clerk-js/src/ui/contexts/CoreClientContext.tsx index 30864cd3ce..044b5dce09 100644 --- a/packages/clerk-js/src/ui/contexts/CoreClientContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreClientContext.tsx @@ -1,4 +1,5 @@ -import { assertContextExists, ClientContext, useClientContext } from '@clerk/shared'; +import { ClientContext, useClientContext } from '@clerk/shared/react'; +import { assertContextExists } from '@clerk/shared/react/hooks'; import type { SessionResource, SignInResource, SignUpResource } from '@clerk/types'; export const CoreClientContext = ClientContext; diff --git a/packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx b/packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx index 5ece45ac17..095124728b 100644 --- a/packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx @@ -1,4 +1,5 @@ -import { OrganizationProvider, useOrganization, useOrganizationList, useOrganizations } from '@clerk/shared'; +import { OrganizationProvider } from '@clerk/shared/react'; +import { useOrganization, useOrganizationList, useOrganizations } from '@clerk/shared/react/hooks'; export const CoreOrganizationProvider = OrganizationProvider; export const useCoreOrganization = useOrganization; diff --git a/packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx b/packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx index d8f4e3f605..386cc64c3e 100644 --- a/packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx @@ -1,4 +1,5 @@ -import { assertContextExists, SessionContext, useSessionContext } from '@clerk/shared'; +import { SessionContext, useSessionContext } from '@clerk/shared/react'; +import { assertContextExists } from '@clerk/shared/react/hooks'; import type { SessionResource } from '@clerk/types'; import React from 'react'; diff --git a/packages/clerk-js/src/ui/contexts/CoreUserContext.tsx b/packages/clerk-js/src/ui/contexts/CoreUserContext.tsx index 350b915f3b..6b8a7b8639 100644 --- a/packages/clerk-js/src/ui/contexts/CoreUserContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreUserContext.tsx @@ -1,4 +1,5 @@ -import { assertContextExists, UserContext, useUserContext } from '@clerk/shared'; +import { UserContext, useUserContext } from '@clerk/shared/react'; +import { assertContextExists } from '@clerk/shared/react/hooks'; import React, { useContext } from 'react'; import { clerkCoreErrorUserIsNotDefined } from '../../core/errors'; diff --git a/packages/clerk-js/src/ui/customizables/AppearanceContext.tsx b/packages/clerk-js/src/ui/customizables/AppearanceContext.tsx index 91f6b8296c..d1afa4f81e 100644 --- a/packages/clerk-js/src/ui/customizables/AppearanceContext.tsx +++ b/packages/clerk-js/src/ui/customizables/AppearanceContext.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import React from 'react'; import { useDeepEqualMemo } from '../hooks'; diff --git a/packages/clerk-js/src/ui/elements/Form.tsx b/packages/clerk-js/src/ui/elements/Form.tsx index 657f1c2425..b35531fbef 100644 --- a/packages/clerk-js/src/ui/elements/Form.tsx +++ b/packages/clerk-js/src/ui/elements/Form.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import type { FieldId } from '@clerk/types'; import React, { useState } from 'react'; diff --git a/packages/clerk-js/src/ui/elements/Menu.tsx b/packages/clerk-js/src/ui/elements/Menu.tsx index 2eeaa3a2ac..51d61e3ab0 100644 --- a/packages/clerk-js/src/ui/elements/Menu.tsx +++ b/packages/clerk-js/src/ui/elements/Menu.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import type { MenuId } from '@clerk/types'; import type { PropsWithChildren } from 'react'; import React, { cloneElement, isValidElement, useLayoutEffect, useRef } from 'react'; diff --git a/packages/clerk-js/src/ui/elements/Modal.tsx b/packages/clerk-js/src/ui/elements/Modal.tsx index af4f568a75..212e5fa4c9 100644 --- a/packages/clerk-js/src/ui/elements/Modal.tsx +++ b/packages/clerk-js/src/ui/elements/Modal.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook, useSafeLayoutEffect } from '@clerk/shared'; +import { createContextAndHook, useSafeLayoutEffect } from '@clerk/shared/react/hooks'; import React, { useRef } from 'react'; import { descriptors, Flex } from '../customizables'; diff --git a/packages/clerk-js/src/ui/elements/Navbar.tsx b/packages/clerk-js/src/ui/elements/Navbar.tsx index d80eeb1d17..ee34a52a2d 100644 --- a/packages/clerk-js/src/ui/elements/Navbar.tsx +++ b/packages/clerk-js/src/ui/elements/Navbar.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook, useSafeLayoutEffect } from '@clerk/shared'; +import { createContextAndHook, useSafeLayoutEffect } from '@clerk/shared/react/hooks'; import type { NavbarItemId } from '@clerk/types'; import React, { useEffect } from 'react'; diff --git a/packages/clerk-js/src/ui/elements/Select.tsx b/packages/clerk-js/src/ui/elements/Select.tsx index f081b51527..8816be07df 100644 --- a/packages/clerk-js/src/ui/elements/Select.tsx +++ b/packages/clerk-js/src/ui/elements/Select.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import type { SelectId } from '@clerk/types'; import type { PropsWithChildren, ReactElement } from 'react'; import React, { useState } from 'react'; diff --git a/packages/clerk-js/src/ui/elements/Tabs.tsx b/packages/clerk-js/src/ui/elements/Tabs.tsx index 9e34c8b0e5..005d0740ca 100644 --- a/packages/clerk-js/src/ui/elements/Tabs.tsx +++ b/packages/clerk-js/src/ui/elements/Tabs.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import type { PropsWithChildren } from 'react'; import React from 'react'; diff --git a/packages/clerk-js/src/ui/elements/TimerButton.tsx b/packages/clerk-js/src/ui/elements/TimerButton.tsx index f4496095ba..7b390e233d 100644 --- a/packages/clerk-js/src/ui/elements/TimerButton.tsx +++ b/packages/clerk-js/src/ui/elements/TimerButton.tsx @@ -1,4 +1,4 @@ -import { useSafeLayoutEffect } from '@clerk/shared'; +import { useSafeLayoutEffect } from '@clerk/shared/react/hooks'; import React, { useEffect } from 'react'; import { Button, useLocalizations } from '../customizables'; diff --git a/packages/clerk-js/src/ui/elements/contexts/CardStateContext.tsx b/packages/clerk-js/src/ui/elements/contexts/CardStateContext.tsx index 9ce1b59e51..2d95792196 100644 --- a/packages/clerk-js/src/ui/elements/contexts/CardStateContext.tsx +++ b/packages/clerk-js/src/ui/elements/contexts/CardStateContext.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import type { ClerkAPIError, ClerkRuntimeError } from '@clerk/types'; import React from 'react'; diff --git a/packages/clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx b/packages/clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx index f547b49fa7..191f747767 100644 --- a/packages/clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx +++ b/packages/clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import React from 'react'; type FlowMetadata = { diff --git a/packages/clerk-js/src/ui/localization/makeLocalizable.tsx b/packages/clerk-js/src/ui/localization/makeLocalizable.tsx index 11f6c9748b..96f4604ed9 100644 --- a/packages/clerk-js/src/ui/localization/makeLocalizable.tsx +++ b/packages/clerk-js/src/ui/localization/makeLocalizable.tsx @@ -1,4 +1,4 @@ -import { isClerkRuntimeError } from '@clerk/shared'; +import { isClerkRuntimeError } from '@clerk/shared/error'; import type { ClerkAPIError, ClerkRuntimeError, LocalizationResource } from '@clerk/types'; import React from 'react'; diff --git a/packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx b/packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx index a739218249..06d559a017 100644 --- a/packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx +++ b/packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import type { ClerkAPIError } from '@clerk/types'; import React from 'react'; diff --git a/packages/clerk-js/src/utils/captcha.ts b/packages/clerk-js/src/utils/captcha.ts index 079817108a..69ab5fbc7c 100644 --- a/packages/clerk-js/src/utils/captcha.ts +++ b/packages/clerk-js/src/utils/captcha.ts @@ -1,4 +1,4 @@ -import { loadScript } from '@clerk/shared'; +import { loadScript } from '@clerk/shared/loadScript'; import { clerkFailedToLoadThirdPartyScript } from '../core/errors'; diff --git a/packages/clerk-js/src/utils/cookies/client.ts b/packages/clerk-js/src/utils/cookies/client.ts index 60ce9cd82c..e1b96625bc 100644 --- a/packages/clerk-js/src/utils/cookies/client.ts +++ b/packages/clerk-js/src/utils/cookies/client.ts @@ -1,4 +1,4 @@ -import { createCookieHandler } from '@clerk/shared'; +import { createCookieHandler } from '@clerk/shared/cookie'; const CLIENT_COOKIE_NAME = '__client'; diff --git a/packages/clerk-js/src/utils/cookies/client_uat.ts b/packages/clerk-js/src/utils/cookies/client_uat.ts index c214efdddd..7125b9e426 100644 --- a/packages/clerk-js/src/utils/cookies/client_uat.ts +++ b/packages/clerk-js/src/utils/cookies/client_uat.ts @@ -1,4 +1,4 @@ -import { createCookieHandler } from '@clerk/shared'; +import { createCookieHandler } from '@clerk/shared/cookie'; const CLIENT_UAT_COOKIE_NAME = '__client_uat'; diff --git a/packages/clerk-js/src/utils/cookies/devBrowser.ts b/packages/clerk-js/src/utils/cookies/devBrowser.ts index 946ca497d0..849d2aef37 100644 --- a/packages/clerk-js/src/utils/cookies/devBrowser.ts +++ b/packages/clerk-js/src/utils/cookies/devBrowser.ts @@ -1,4 +1,4 @@ -import { createCookieHandler } from '@clerk/shared'; +import { createCookieHandler } from '@clerk/shared/cookie'; import { DEV_BROWSER_JWT_MARKER } from '../devBrowser'; diff --git a/packages/clerk-js/src/utils/cookies/initted.ts b/packages/clerk-js/src/utils/cookies/initted.ts index 42dcad0268..16db5a4be0 100644 --- a/packages/clerk-js/src/utils/cookies/initted.ts +++ b/packages/clerk-js/src/utils/cookies/initted.ts @@ -1,4 +1,4 @@ -import { createCookieHandler } from '@clerk/shared'; +import { createCookieHandler } from '@clerk/shared/cookie'; const INITTED_COOKIE_NAME = '__initted'; diff --git a/packages/clerk-js/src/utils/cookies/session.ts b/packages/clerk-js/src/utils/cookies/session.ts index 222d0af611..34c8872eeb 100644 --- a/packages/clerk-js/src/utils/cookies/session.ts +++ b/packages/clerk-js/src/utils/cookies/session.ts @@ -1,4 +1,4 @@ -import { createCookieHandler } from '@clerk/shared'; +import { createCookieHandler } from '@clerk/shared/cookie'; const SESSION_COOKIE_NAME = '__session'; diff --git a/packages/clerk-js/src/utils/errorThrower.ts b/packages/clerk-js/src/utils/errorThrower.ts index b3d4f97263..b2c4437b31 100644 --- a/packages/clerk-js/src/utils/errorThrower.ts +++ b/packages/clerk-js/src/utils/errorThrower.ts @@ -1,4 +1,4 @@ -import { buildErrorThrower } from '@clerk/shared'; +import { buildErrorThrower } from '@clerk/shared/error'; const errorThrower = buildErrorThrower({ packageName: __PKG_NAME__ }); diff --git a/packages/clerk-js/src/utils/image.ts b/packages/clerk-js/src/utils/image.ts index 0b8ccf701f..12006582a1 100644 --- a/packages/clerk-js/src/utils/image.ts +++ b/packages/clerk-js/src/utils/image.ts @@ -1,4 +1,4 @@ -import { isomorphicAtob } from '@clerk/shared'; +import { isomorphicAtob } from '@clerk/shared/isomorphicAtob'; /** * @private diff --git a/packages/clerk-js/src/utils/jwt.ts b/packages/clerk-js/src/utils/jwt.ts index 2177dbd4c0..e0f96218e7 100644 --- a/packages/clerk-js/src/utils/jwt.ts +++ b/packages/clerk-js/src/utils/jwt.ts @@ -1,4 +1,4 @@ -import { deprecatedObjectProperty } from '@clerk/shared'; +import { deprecatedObjectProperty } from '@clerk/shared/deprecated'; import type { JWT, JWTClaims } from '@clerk/types'; import { urlDecodeB64 } from './encoders'; diff --git a/packages/clerk-js/src/utils/pageLifecycle.ts b/packages/clerk-js/src/utils/pageLifecycle.ts index 7f9cd15287..eae6ee697d 100644 --- a/packages/clerk-js/src/utils/pageLifecycle.ts +++ b/packages/clerk-js/src/utils/pageLifecycle.ts @@ -1,4 +1,4 @@ -import { inBrowser } from '@clerk/shared'; +import { inBrowser } from '@clerk/shared/browser'; const noop = () => { // diff --git a/packages/clerk-js/src/utils/url.ts b/packages/clerk-js/src/utils/url.ts index a4e08b0c09..a258a39021 100644 --- a/packages/clerk-js/src/utils/url.ts +++ b/packages/clerk-js/src/utils/url.ts @@ -1,4 +1,5 @@ -import { camelToSnake, createDevOrStagingUrlCache, globs } from '@clerk/shared'; +import { camelToSnake, createDevOrStagingUrlCache } from '@clerk/shared'; +import { globs } from '@clerk/shared/globs'; import type { SignUpResource } from '@clerk/types'; import { joinPaths } from './path'; diff --git a/packages/clerk-js/tsconfig.json b/packages/clerk-js/tsconfig.json index c422f4aa8f..0c6639918a 100644 --- a/packages/clerk-js/tsconfig.json +++ b/packages/clerk-js/tsconfig.json @@ -7,7 +7,7 @@ "isolatedModules": true, "module": "esnext", "lib": ["es2021.intl"], - "moduleResolution": "Node", + "moduleResolution": "NodeNext", "noEmit": true, "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, From 3a7b7afd0f7d1ac69b51803032ce51e59776859e Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 15:53:11 +0200 Subject: [PATCH 30/53] fix(clerk-expo): Updat imports --- packages/expo/src/ClerkProvider.tsx | 2 +- packages/expo/tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/expo/src/ClerkProvider.tsx b/packages/expo/src/ClerkProvider.tsx index f2563956ae..136ce8b28f 100644 --- a/packages/expo/src/ClerkProvider.tsx +++ b/packages/expo/src/ClerkProvider.tsx @@ -3,7 +3,7 @@ import './polyfills'; import type { ClerkProviderProps as ClerkReactProviderProps } from '@clerk/clerk-react'; import { __internal__setErrorThrowerOptions, ClerkProvider as ClerkReactProvider } from '@clerk/clerk-react'; -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import React from 'react'; import type { TokenCache } from './cache'; diff --git a/packages/expo/tsconfig.json b/packages/expo/tsconfig.json index 339f1c1697..650f0cf2ee 100644 --- a/packages/expo/tsconfig.json +++ b/packages/expo/tsconfig.json @@ -5,7 +5,7 @@ "lib": ["es6", "dom"], "jsx": "react", "module": "commonjs", - "moduleResolution": "node", + "moduleResolution": "NodeNext", "importHelpers": true, "declaration": true, "declarationMap": false, From 2ae0fa685210d1118796597c3495df902c18e231 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 15:54:18 +0200 Subject: [PATCH 31/53] fix(fastify): Update imports --- packages/fastify/src/constants.ts | 2 +- packages/fastify/tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/fastify/src/constants.ts b/packages/fastify/src/constants.ts index da0a6cd5bd..3a1e1b4836 100644 --- a/packages/fastify/src/constants.ts +++ b/packages/fastify/src/constants.ts @@ -1,6 +1,6 @@ /* eslint-disable turbo/no-undeclared-env-vars */ import { constants } from '@clerk/backend'; -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; export const API_URL = process.env.CLERK_API_URL || 'https://api.clerk.dev'; export const API_VERSION = process.env.CLERK_API_VERSION || 'v1'; diff --git a/packages/fastify/tsconfig.json b/packages/fastify/tsconfig.json index ec21549562..36221e05f4 100644 --- a/packages/fastify/tsconfig.json +++ b/packages/fastify/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "moduleResolution": "node", + "moduleResolution": "NodeNext", "sourceMap": false, "strict": true, "esModuleInterop": true, From d669ec954bde3383778f744a4b383a5b96a8d120 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 15:55:33 +0200 Subject: [PATCH 32/53] fix(gatsby): Update imports --- packages/gatsby-plugin-clerk/src/constants.ts | 2 +- packages/gatsby-plugin-clerk/tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-plugin-clerk/src/constants.ts b/packages/gatsby-plugin-clerk/src/constants.ts index 682dbbc41d..608f1f6772 100644 --- a/packages/gatsby-plugin-clerk/src/constants.ts +++ b/packages/gatsby-plugin-clerk/src/constants.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; export const API_URL = process.env.CLERK_API_URL || 'https://api.clerk.dev'; export const API_VERSION = process.env.CLERK_API_VERSION || 'v1'; diff --git a/packages/gatsby-plugin-clerk/tsconfig.json b/packages/gatsby-plugin-clerk/tsconfig.json index 339f1c1697..650f0cf2ee 100644 --- a/packages/gatsby-plugin-clerk/tsconfig.json +++ b/packages/gatsby-plugin-clerk/tsconfig.json @@ -5,7 +5,7 @@ "lib": ["es6", "dom"], "jsx": "react", "module": "commonjs", - "moduleResolution": "node", + "moduleResolution": "NodeNext", "importHelpers": true, "declaration": true, "declarationMap": false, From 1f653bde95ad9b0ea20a9a9d2a0729cb6a8ca041 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 15:57:55 +0200 Subject: [PATCH 33/53] fix(next): Update imports --- packages/nextjs/src/app-beta/ClerkProvider.tsx | 2 +- packages/nextjs/src/app-beta/auth.ts | 2 +- packages/nextjs/src/app-beta/clerkClient.ts | 2 +- packages/nextjs/src/app-beta/client/ClerkProvider.tsx | 2 +- packages/nextjs/src/app-beta/client/ui-components.tsx | 2 +- packages/nextjs/src/app-beta/control-components.tsx | 2 +- packages/nextjs/src/app-beta/currentUser.ts | 2 +- packages/nextjs/src/server/constants.ts | 2 +- packages/nextjs/src/server/withClerkMiddleware.ts | 2 +- packages/nextjs/src/ssr/withServerSideAuth.ts | 2 +- packages/nextjs/tsconfig.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/nextjs/src/app-beta/ClerkProvider.tsx b/packages/nextjs/src/app-beta/ClerkProvider.tsx index 6147b4f1de..c467ec694e 100644 --- a/packages/nextjs/src/app-beta/ClerkProvider.tsx +++ b/packages/nextjs/src/app-beta/ClerkProvider.tsx @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; deprecated( '@clerk/nextjs/app-beta', diff --git a/packages/nextjs/src/app-beta/auth.ts b/packages/nextjs/src/app-beta/auth.ts index e9be20b298..74d31afc37 100644 --- a/packages/nextjs/src/app-beta/auth.ts +++ b/packages/nextjs/src/app-beta/auth.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; deprecated( '@clerk/nextjs/app-beta', diff --git a/packages/nextjs/src/app-beta/clerkClient.ts b/packages/nextjs/src/app-beta/clerkClient.ts index 9f01e147df..b681f8bfb6 100644 --- a/packages/nextjs/src/app-beta/clerkClient.ts +++ b/packages/nextjs/src/app-beta/clerkClient.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; deprecated( '@clerk/nextjs/app-beta', diff --git a/packages/nextjs/src/app-beta/client/ClerkProvider.tsx b/packages/nextjs/src/app-beta/client/ClerkProvider.tsx index ab833405fd..25e6a06a1a 100644 --- a/packages/nextjs/src/app-beta/client/ClerkProvider.tsx +++ b/packages/nextjs/src/app-beta/client/ClerkProvider.tsx @@ -1,5 +1,5 @@ 'use client'; -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; deprecated( '@clerk/nextjs/app-beta', diff --git a/packages/nextjs/src/app-beta/client/ui-components.tsx b/packages/nextjs/src/app-beta/client/ui-components.tsx index da5f93837b..f7c4a0d389 100644 --- a/packages/nextjs/src/app-beta/client/ui-components.tsx +++ b/packages/nextjs/src/app-beta/client/ui-components.tsx @@ -1,5 +1,5 @@ 'use client'; -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; deprecated( '@clerk/nextjs/app-beta', diff --git a/packages/nextjs/src/app-beta/control-components.tsx b/packages/nextjs/src/app-beta/control-components.tsx index 95f6f47656..59974404d9 100644 --- a/packages/nextjs/src/app-beta/control-components.tsx +++ b/packages/nextjs/src/app-beta/control-components.tsx @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import React from 'react'; deprecated( diff --git a/packages/nextjs/src/app-beta/currentUser.ts b/packages/nextjs/src/app-beta/currentUser.ts index 308f0ab668..e1be302607 100644 --- a/packages/nextjs/src/app-beta/currentUser.ts +++ b/packages/nextjs/src/app-beta/currentUser.ts @@ -1,5 +1,5 @@ import type { User } from '@clerk/backend'; -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; deprecated( '@clerk/nextjs/app-beta', diff --git a/packages/nextjs/src/server/constants.ts b/packages/nextjs/src/server/constants.ts index c5c3eb7115..e7682801ee 100644 --- a/packages/nextjs/src/server/constants.ts +++ b/packages/nextjs/src/server/constants.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; /** * @deprecated Use `CLERK_JS_VERSION` instead. diff --git a/packages/nextjs/src/server/withClerkMiddleware.ts b/packages/nextjs/src/server/withClerkMiddleware.ts index 0beca065c5..433cdad862 100644 --- a/packages/nextjs/src/server/withClerkMiddleware.ts +++ b/packages/nextjs/src/server/withClerkMiddleware.ts @@ -1,6 +1,6 @@ import type { RequestState } from '@clerk/backend'; import { constants, debugRequestState } from '@clerk/backend'; -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { NextFetchEvent, NextMiddleware, NextRequest } from 'next/server'; import { NextResponse } from 'next/server'; diff --git a/packages/nextjs/src/ssr/withServerSideAuth.ts b/packages/nextjs/src/ssr/withServerSideAuth.ts index 409e47ba49..e9baa11722 100644 --- a/packages/nextjs/src/ssr/withServerSideAuth.ts +++ b/packages/nextjs/src/ssr/withServerSideAuth.ts @@ -1,6 +1,6 @@ import type { RequestState } from '@clerk/backend'; import { constants, debugRequestState } from '@clerk/backend'; -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { ServerResponse } from 'http'; import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next'; diff --git a/packages/nextjs/tsconfig.json b/packages/nextjs/tsconfig.json index b74f37fa41..8bdd1fea4c 100644 --- a/packages/nextjs/tsconfig.json +++ b/packages/nextjs/tsconfig.json @@ -10,7 +10,7 @@ "jsx": "react", "lib": ["es6", "dom"], "module": "commonjs", - "moduleResolution": "node", + "moduleResolution": "NodeNext", "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, From 36fd977e5afab018a8ec61959e37fc0fe8193b2f Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 16:03:19 +0200 Subject: [PATCH 34/53] fix(react): Update imports --- packages/react/src/contexts/AuthContext.ts | 2 +- packages/react/src/contexts/ClerkContextProvider.tsx | 2 +- packages/react/src/contexts/ClientContext.tsx | 2 +- packages/react/src/contexts/IsomorphicClerkContext.tsx | 2 +- packages/react/src/contexts/OrganizationContext.tsx | 2 +- packages/react/src/contexts/SessionContext.tsx | 2 +- packages/react/src/contexts/UserContext.tsx | 2 +- packages/react/src/errors.ts | 2 +- packages/react/src/hooks/useMagicLink.ts | 2 +- packages/react/src/hooks/useOrganization.ts | 2 +- packages/react/src/hooks/useOrganizationList.ts | 2 +- packages/react/src/hooks/useOrganizations.ts | 2 +- packages/react/src/utils/errorThrower.ts | 4 ++-- packages/react/tsconfig.json | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/react/src/contexts/AuthContext.ts b/packages/react/src/contexts/AuthContext.ts index d7ae34a938..c6d9f6292b 100644 --- a/packages/react/src/contexts/AuthContext.ts +++ b/packages/react/src/contexts/AuthContext.ts @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared'; +import { createContextAndHook } from '@clerk/shared/react/hooks'; import type { ActJWTClaim, MembershipRole } from '@clerk/types'; export const [AuthContext, useAuthContext] = createContextAndHook<{ diff --git a/packages/react/src/contexts/ClerkContextProvider.tsx b/packages/react/src/contexts/ClerkContextProvider.tsx index 84948aff11..432444fc40 100644 --- a/packages/react/src/contexts/ClerkContextProvider.tsx +++ b/packages/react/src/contexts/ClerkContextProvider.tsx @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { ClientResource, InitialState, Resources } from '@clerk/types'; import React from 'react'; diff --git a/packages/react/src/contexts/ClientContext.tsx b/packages/react/src/contexts/ClientContext.tsx index ea29bce0f6..7dd27732e1 100644 --- a/packages/react/src/contexts/ClientContext.tsx +++ b/packages/react/src/contexts/ClientContext.tsx @@ -1 +1 @@ -export { ClientContext, useClientContext } from '@clerk/shared'; +export { ClientContext, useClientContext } from '@clerk/shared/react'; diff --git a/packages/react/src/contexts/IsomorphicClerkContext.tsx b/packages/react/src/contexts/IsomorphicClerkContext.tsx index 2de3f1c6e6..fc2476711b 100644 --- a/packages/react/src/contexts/IsomorphicClerkContext.tsx +++ b/packages/react/src/contexts/IsomorphicClerkContext.tsx @@ -1,3 +1,3 @@ -import { ClerkInstanceContext, useClerkInstanceContext } from '@clerk/shared'; +import { ClerkInstanceContext, useClerkInstanceContext } from '@clerk/shared/react'; export const [IsomorphicClerkContext, useIsomorphicClerkContext] = [ClerkInstanceContext, useClerkInstanceContext]; diff --git a/packages/react/src/contexts/OrganizationContext.tsx b/packages/react/src/contexts/OrganizationContext.tsx index 13ed6bf2e2..f6f820acfa 100644 --- a/packages/react/src/contexts/OrganizationContext.tsx +++ b/packages/react/src/contexts/OrganizationContext.tsx @@ -1 +1 @@ -export { OrganizationProvider, OrganizationContext, useOrganizationContext } from '@clerk/shared'; +export { OrganizationProvider, OrganizationContext, useOrganizationContext } from '@clerk/shared/react'; diff --git a/packages/react/src/contexts/SessionContext.tsx b/packages/react/src/contexts/SessionContext.tsx index 174509b795..4de2102593 100644 --- a/packages/react/src/contexts/SessionContext.tsx +++ b/packages/react/src/contexts/SessionContext.tsx @@ -1 +1 @@ -export { SessionContext, useSessionContext } from '@clerk/shared'; +export { SessionContext, useSessionContext } from '@clerk/shared/react'; diff --git a/packages/react/src/contexts/UserContext.tsx b/packages/react/src/contexts/UserContext.tsx index 8c5c75ff58..c5ef71321e 100644 --- a/packages/react/src/contexts/UserContext.tsx +++ b/packages/react/src/contexts/UserContext.tsx @@ -1 +1 @@ -export { UserContext, useUserContext } from '@clerk/shared'; +export { UserContext, useUserContext } from '@clerk/shared/react'; diff --git a/packages/react/src/errors.ts b/packages/react/src/errors.ts index 739f04142f..4e567a9742 100644 --- a/packages/react/src/errors.ts +++ b/packages/react/src/errors.ts @@ -6,7 +6,7 @@ export { isMetamaskError, isMagicLinkError, isEmailLinkError, -} from '@clerk/shared'; +} from '@clerk/shared/error'; export const noFrontendApiError = 'Clerk: You must add the frontendApi prop to your '; diff --git a/packages/react/src/hooks/useMagicLink.ts b/packages/react/src/hooks/useMagicLink.ts index 673f62c1d3..9db5743931 100644 --- a/packages/react/src/hooks/useMagicLink.ts +++ b/packages/react/src/hooks/useMagicLink.ts @@ -1,4 +1,4 @@ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { CreateMagicLinkFlowReturn, EmailAddressResource, diff --git a/packages/react/src/hooks/useOrganization.ts b/packages/react/src/hooks/useOrganization.ts index 175145ff0a..34547dfd33 100644 --- a/packages/react/src/hooks/useOrganization.ts +++ b/packages/react/src/hooks/useOrganization.ts @@ -1 +1 @@ -export { useOrganization } from '@clerk/shared'; +export { useOrganization } from '@clerk/shared/react/hooks'; diff --git a/packages/react/src/hooks/useOrganizationList.ts b/packages/react/src/hooks/useOrganizationList.ts index 7b4192401b..362fd40f6e 100644 --- a/packages/react/src/hooks/useOrganizationList.ts +++ b/packages/react/src/hooks/useOrganizationList.ts @@ -1 +1 @@ -export { useOrganizationList } from '@clerk/shared'; +export { useOrganizationList } from '@clerk/shared/react/hooks'; diff --git a/packages/react/src/hooks/useOrganizations.ts b/packages/react/src/hooks/useOrganizations.ts index 36174f1958..ee84bbea08 100644 --- a/packages/react/src/hooks/useOrganizations.ts +++ b/packages/react/src/hooks/useOrganizations.ts @@ -1 +1 @@ -export { useOrganizations } from '@clerk/shared'; +export { useOrganizations } from '@clerk/shared/react/hooks'; diff --git a/packages/react/src/utils/errorThrower.ts b/packages/react/src/utils/errorThrower.ts index 853da1baee..66f0290d9d 100644 --- a/packages/react/src/utils/errorThrower.ts +++ b/packages/react/src/utils/errorThrower.ts @@ -1,5 +1,5 @@ -import type { ErrorThrowerOptions } from '@clerk/shared'; -import { buildErrorThrower } from '@clerk/shared'; +import type { ErrorThrowerOptions } from '@clerk/shared/error'; +import { buildErrorThrower } from '@clerk/shared/error'; const errorThrower = buildErrorThrower({ packageName: '@clerk/react' }); diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index 71b3019c59..a66008741d 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -8,7 +8,7 @@ "isolatedModules": true, "jsx": "react", "lib": ["es6", "dom"], - "moduleResolution": "node", + "moduleResolution": "NodeNext", "noImplicitReturns": true, "noUnusedLocals": false, "noUnusedParameters": true, From 741e7c3ee642b49a2664704ce6010cbbf09b3fd6 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 16:04:03 +0200 Subject: [PATCH 35/53] fix(remix): Update imports --- packages/remix/src/errorThrower.ts | 4 ++-- packages/remix/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/remix/src/errorThrower.ts b/packages/remix/src/errorThrower.ts index 68fc22437e..a7f17471d0 100644 --- a/packages/remix/src/errorThrower.ts +++ b/packages/remix/src/errorThrower.ts @@ -1,5 +1,5 @@ -import type { ErrorThrowerOptions } from '@clerk/shared'; -import { buildErrorThrower } from '@clerk/shared'; +import type { ErrorThrowerOptions } from '@clerk/shared/error'; +import { buildErrorThrower } from '@clerk/shared/error'; const errorThrower = buildErrorThrower({ packageName: '@clerk/remix' }); diff --git a/packages/remix/tsconfig.json b/packages/remix/tsconfig.json index 339f1c1697..650f0cf2ee 100644 --- a/packages/remix/tsconfig.json +++ b/packages/remix/tsconfig.json @@ -5,7 +5,7 @@ "lib": ["es6", "dom"], "jsx": "react", "module": "commonjs", - "moduleResolution": "node", + "moduleResolution": "NodeNext", "importHelpers": true, "declaration": true, "declarationMap": false, From 77f96e646416ddc782caa7a5ca9ee315ac312721 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 16:18:17 +0200 Subject: [PATCH 36/53] chore(shared): Rename and move multiDomain --- .../multiDomain.test.ts => __tests__/handleValueOrFn.test.ts} | 2 +- .../shared/src/{utils/multiDomain.ts => handleValueOrFn.ts} | 0 packages/shared/src/index.ts | 1 + packages/shared/src/utils/index.ts | 1 - 4 files changed, 2 insertions(+), 2 deletions(-) rename packages/shared/src/{utils/__tests__/multiDomain.test.ts => __tests__/handleValueOrFn.test.ts} (94%) rename packages/shared/src/{utils/multiDomain.ts => handleValueOrFn.ts} (100%) diff --git a/packages/shared/src/utils/__tests__/multiDomain.test.ts b/packages/shared/src/__tests__/handleValueOrFn.test.ts similarity index 94% rename from packages/shared/src/utils/__tests__/multiDomain.test.ts rename to packages/shared/src/__tests__/handleValueOrFn.test.ts index 1f9c8694ef..e48a321c14 100644 --- a/packages/shared/src/utils/__tests__/multiDomain.test.ts +++ b/packages/shared/src/__tests__/handleValueOrFn.test.ts @@ -1,4 +1,4 @@ -import { handleValueOrFn } from '../multiDomain'; +import { handleValueOrFn } from '../handleValueOrFn'; const url = new URL('https://example.com'); diff --git a/packages/shared/src/utils/multiDomain.ts b/packages/shared/src/handleValueOrFn.ts similarity index 100% rename from packages/shared/src/utils/multiDomain.ts rename to packages/shared/src/handleValueOrFn.ts diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 8e9fbb809e..f572339a09 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -17,6 +17,7 @@ export * from './date'; export * from './deprecated'; export * from './error'; export * from './file'; +export { handleValueOrFn } from './handleValueOrFn'; export { isomorphicAtob } from './isomorphicAtob'; export * from './keys'; export { loadScript } from './loadScript'; diff --git a/packages/shared/src/utils/index.ts b/packages/shared/src/utils/index.ts index 0d4ef5662a..8d2ae051ce 100644 --- a/packages/shared/src/utils/index.ts +++ b/packages/shared/src/utils/index.ts @@ -1,7 +1,6 @@ export { callWithRetry } from './callWithRetry'; export * from './createDeferredPromise'; export { isDevelopmentFromApiKey, isProductionFromApiKey, isStaging } from './instance'; -export * from './multiDomain'; export { noop } from './noop'; export * from './runtimeEnvironment'; export * from './runWithExponentialBackOff'; From 3e856cd4bc621845b5d26ad66d3c0abf6320f578 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 16:19:20 +0200 Subject: [PATCH 37/53] fix(sdk-node): Use new imports --- packages/sdk-node/src/authenticateRequest.ts | 3 +- packages/sdk-node/src/shared.ts | 45 -------------------- packages/sdk-node/src/utils.ts | 2 +- packages/sdk-node/tsconfig.json | 2 +- 4 files changed, 4 insertions(+), 48 deletions(-) delete mode 100644 packages/sdk-node/src/shared.ts diff --git a/packages/sdk-node/src/authenticateRequest.ts b/packages/sdk-node/src/authenticateRequest.ts index f4acb71810..d710b24332 100644 --- a/packages/sdk-node/src/authenticateRequest.ts +++ b/packages/sdk-node/src/authenticateRequest.ts @@ -1,8 +1,9 @@ import type { RequestState } from '@clerk/backend'; import { buildRequestUrl, constants, createIsomorphicRequest } from '@clerk/backend'; +import { handleValueOrFn } from '@clerk/shared/handleValueOrFn'; +import { isHttpOrHttps, isProxyUrlRelative, isValidProxyUrl } from '@clerk/shared/proxy'; import type { ServerResponse } from 'http'; -import { handleValueOrFn, isHttpOrHttps, isProxyUrlRelative, isValidProxyUrl } from './shared'; import type { AuthenticateRequestParams, ClerkClient } from './types'; import { loadApiEnv, loadClientEnv } from './utils'; diff --git a/packages/sdk-node/src/shared.ts b/packages/sdk-node/src/shared.ts deleted file mode 100644 index 1e125eab2c..0000000000 --- a/packages/sdk-node/src/shared.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * These functions originate from @clerk/shared - * Maintain these until @clerk/shared does not depend on react - */ -export function isValidProxyUrl(key: string | undefined) { - if (!key) { - return true; - } - - return isHttpOrHttps(key) || isProxyUrlRelative(key); -} - -export function isHttpOrHttps(key: string | undefined) { - return /^http(s)?:\/\//.test(key || ''); -} - -export function isProxyUrlRelative(key: string) { - return key.startsWith('/'); -} - -export function proxyUrlToAbsoluteURL(url: string | undefined): string { - if (!url) { - return ''; - } - return isProxyUrlRelative(url) ? new URL(url, window.location.origin).toString() : url; -} - -type VOrFnReturnsV = T | undefined | ((v: URL) => T); -export function handleValueOrFn(value: VOrFnReturnsV, url: URL): T | undefined; -export function handleValueOrFn(value: VOrFnReturnsV, url: URL, defaultValue: T): T; -export function handleValueOrFn(value: VOrFnReturnsV, url: URL, defaultValue?: unknown): unknown { - if (typeof value === 'function') { - return (value as (v: URL) => T)(url); - } - - if (typeof value !== 'undefined') { - return value; - } - - if (typeof defaultValue !== 'undefined') { - return defaultValue; - } - - return undefined; -} diff --git a/packages/sdk-node/src/utils.ts b/packages/sdk-node/src/utils.ts index 537f5279da..331495f4b1 100644 --- a/packages/sdk-node/src/utils.ts +++ b/packages/sdk-node/src/utils.ts @@ -1,5 +1,5 @@ /* eslint-disable turbo/no-undeclared-env-vars */ -import { deprecated } from '@clerk/shared'; +import { deprecated } from '@clerk/shared/deprecated'; import type { IncomingMessage, ServerResponse } from 'http'; // https://nextjs.org/docs/api-routes/api-middlewares#connectexpress-middleware-support diff --git a/packages/sdk-node/tsconfig.json b/packages/sdk-node/tsconfig.json index 9579a15f86..ae3cbe23da 100644 --- a/packages/sdk-node/tsconfig.json +++ b/packages/sdk-node/tsconfig.json @@ -6,7 +6,7 @@ "forceConsistentCasingInFileNames": true, "importHelpers": true, "isolatedModules": true, - "moduleResolution": "node", + "moduleResolution": "NodeNext", "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, From df79223e1e07aaaf14a37260b1f2911ca3848435 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Thu, 12 Oct 2023 16:48:32 +0200 Subject: [PATCH 38/53] update lock file --- package-lock.json | 96 +++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7ece751684..d2b2773023 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30191,11 +30191,11 @@ }, "packages/backend": { "name": "@clerk/backend", - "version": "0.30.3", + "version": "0.31.0", "license": "MIT", "dependencies": { - "@clerk/shared": "0.24.3", - "@clerk/types": "3.54.0", + "@clerk/shared": "0.24.4", + "@clerk/types": "3.55.0", "@peculiar/webcrypto": "1.4.1", "@types/node": "16.18.6", "cookie": "0.5.0", @@ -30236,11 +30236,11 @@ }, "packages/chrome-extension": { "name": "@clerk/chrome-extension", - "version": "0.4.6", + "version": "0.4.7", "license": "MIT", "dependencies": { - "@clerk/clerk-js": "4.60.1", - "@clerk/clerk-react": "4.26.3" + "@clerk/clerk-js": "4.61.0", + "@clerk/clerk-react": "4.26.4" }, "devDependencies": { "@types/chrome": "*", @@ -30256,12 +30256,12 @@ }, "packages/clerk-js": { "name": "@clerk/clerk-js", - "version": "4.60.1", + "version": "4.61.0", "license": "MIT", "dependencies": { - "@clerk/localizations": "1.26.3", - "@clerk/shared": "0.24.3", - "@clerk/types": "3.54.0", + "@clerk/localizations": "1.26.4", + "@clerk/shared": "0.24.4", + "@clerk/types": "3.55.0", "@emotion/cache": "11.10.5", "@emotion/react": "11.10.5", "@floating-ui/react": "0.25.4", @@ -30595,17 +30595,17 @@ }, "packages/expo": { "name": "@clerk/clerk-expo", - "version": "0.19.8", + "version": "0.19.9", "license": "MIT", "dependencies": { - "@clerk/clerk-js": "4.60.1", - "@clerk/clerk-react": "4.26.3", - "@clerk/shared": "0.24.3", + "@clerk/clerk-js": "4.61.0", + "@clerk/clerk-react": "4.26.4", + "@clerk/shared": "0.24.4", "base-64": "1.0.0", "react-native-url-polyfill": "2.0.0" }, "devDependencies": { - "@clerk/types": "^3.54.0", + "@clerk/types": "^3.55.0", "@types/base-64": "^1.0.0", "@types/node": "^16.11.55", "@types/react": "*", @@ -30626,12 +30626,12 @@ }, "packages/fastify": { "name": "@clerk/fastify", - "version": "0.6.13", + "version": "0.6.14", "license": "MIT", "dependencies": { - "@clerk/backend": "0.30.3", - "@clerk/shared": "0.24.3", - "@clerk/types": "3.54.0", + "@clerk/backend": "0.31.0", + "@clerk/shared": "0.24.4", + "@clerk/types": "3.55.0", "cookies": "0.8.0" }, "devDependencies": { @@ -30647,13 +30647,13 @@ } }, "packages/gatsby-plugin-clerk": { - "version": "4.4.14", + "version": "4.4.15", "license": "MIT", "dependencies": { - "@clerk/backend": "0.30.3", - "@clerk/clerk-react": "4.26.3", - "@clerk/clerk-sdk-node": "4.12.12", - "@clerk/types": "3.54.0", + "@clerk/backend": "0.31.0", + "@clerk/clerk-react": "4.26.4", + "@clerk/clerk-sdk-node": "4.12.13", + "@clerk/types": "3.55.0", "cookie": "0.5.0", "tslib": "2.4.1" }, @@ -30676,10 +30676,10 @@ }, "packages/localizations": { "name": "@clerk/localizations", - "version": "1.26.3", + "version": "1.26.4", "license": "MIT", "dependencies": { - "@clerk/types": "3.54.0" + "@clerk/types": "3.55.0" }, "devDependencies": { "tsup": "*", @@ -30694,14 +30694,14 @@ }, "packages/nextjs": { "name": "@clerk/nextjs", - "version": "4.25.3", + "version": "4.25.4", "license": "MIT", "dependencies": { - "@clerk/backend": "0.30.3", - "@clerk/clerk-react": "4.26.3", - "@clerk/clerk-sdk-node": "4.12.12", - "@clerk/shared": "0.24.3", - "@clerk/types": "3.54.0", + "@clerk/backend": "0.31.0", + "@clerk/clerk-react": "4.26.4", + "@clerk/clerk-sdk-node": "4.12.13", + "@clerk/shared": "0.24.4", + "@clerk/types": "3.55.0", "path-to-regexp": "6.2.1", "tslib": "2.4.1" }, @@ -30733,11 +30733,11 @@ }, "packages/react": { "name": "@clerk/clerk-react", - "version": "4.26.3", + "version": "4.26.4", "license": "MIT", "dependencies": { - "@clerk/shared": "0.24.3", - "@clerk/types": "3.54.0", + "@clerk/shared": "0.24.4", + "@clerk/types": "3.55.0", "tslib": "2.4.1" }, "devDependencies": { @@ -30759,13 +30759,13 @@ }, "packages/remix": { "name": "@clerk/remix", - "version": "3.0.5", + "version": "3.0.6", "license": "MIT", "dependencies": { - "@clerk/backend": "0.30.3", - "@clerk/clerk-react": "4.26.3", - "@clerk/shared": "0.24.3", - "@clerk/types": "3.54.0", + "@clerk/backend": "0.31.0", + "@clerk/clerk-react": "4.26.4", + "@clerk/shared": "0.24.4", + "@clerk/types": "3.55.0", "cookie": "0.5.0", "tslib": "2.4.1" }, @@ -30794,12 +30794,12 @@ }, "packages/sdk-node": { "name": "@clerk/clerk-sdk-node", - "version": "4.12.12", + "version": "4.12.13", "license": "MIT", "dependencies": { - "@clerk/backend": "0.30.3", - "@clerk/shared": "0.24.3", - "@clerk/types": "3.54.0", + "@clerk/backend": "0.31.0", + "@clerk/shared": "0.24.4", + "@clerk/types": "3.55.0", "@types/cookies": "0.7.7", "@types/express": "4.17.14", "@types/node-fetch": "2.6.2", @@ -30835,7 +30835,7 @@ }, "packages/shared": { "name": "@clerk/shared", - "version": "0.24.3", + "version": "0.24.4", "license": "MIT", "dependencies": { "glob-to-regexp": "0.4.1", @@ -30843,7 +30843,7 @@ "swr": "2.2.0" }, "devDependencies": { - "@clerk/types": "3.54.0", + "@clerk/types": "3.55.0", "@types/glob-to-regexp": "0.4.1", "@types/js-cookie": "3.0.2", "tsup": "*", @@ -30863,7 +30863,7 @@ "version": "1.7.7", "license": "MIT", "devDependencies": { - "@clerk/types": "3.54.0", + "@clerk/types": "3.55.0", "typescript": "*" }, "engines": { @@ -30875,7 +30875,7 @@ }, "packages/types": { "name": "@clerk/types", - "version": "3.54.0", + "version": "3.55.0", "license": "MIT", "dependencies": { "csstype": "3.1.1" From 2fb29798ddd21d6b1adc40dcc3703fcd24b909f3 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Fri, 13 Oct 2023 12:02:01 +0200 Subject: [PATCH 39/53] fix(clerk-js): Adjust webpack config --- packages/clerk-js/webpack.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/clerk-js/webpack.config.js b/packages/clerk-js/webpack.config.js index 9f945187cb..ee9226b37e 100644 --- a/packages/clerk-js/webpack.config.js +++ b/packages/clerk-js/webpack.config.js @@ -29,7 +29,7 @@ const common = ({ mode }) => { return { mode, resolve: { - extensions: ['.ts', '.tsx', '.js', '.jsx'], + extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'], }, plugins: [ new webpack.DefinePlugin({ @@ -100,7 +100,7 @@ const svgLoader = () => { /** @type { () => (import('webpack').RuleSetRule) } */ const typescriptLoaderProd = () => { return { - test: /\.(ts|js)x?$/, + test: /\.(js|mjs|jsx|ts|tsx)$/, exclude: /node_modules/, resolve: { fullySpecified: false, @@ -117,7 +117,7 @@ const typescriptLoaderProd = () => { /** @type { () => (import('webpack').RuleSetRule) } */ const typescriptLoaderDev = () => { return { - test: /\.(ts|js)x?$/, + test: /\.(js|mjs|jsx|ts|tsx)$/, exclude: /node_modules/, resolve: { fullySpecified: false, From 83cfe18895e223e6b639344b999386e4caaccbc4 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Fri, 13 Oct 2023 12:02:40 +0200 Subject: [PATCH 40/53] chore(repo): Make TS compilation work with TS 5 --- package-lock.json | 81 +++++++------------ package.json | 2 +- packages/backend/tsconfig.json | 1 + packages/clerk-js/package.json | 4 +- .../src/ui/elements/ArrowBlockButton.tsx | 2 +- .../clerk-js/src/ui/elements/IconButton.tsx | 2 +- .../clerk-js/src/ui/styledSystem/types.ts | 2 +- packages/clerk-js/tsconfig.declarations.json | 3 +- packages/clerk-js/tsconfig.json | 3 +- packages/expo/tsconfig.json | 2 +- packages/fastify/tsconfig.json | 1 + packages/gatsby-plugin-clerk/tsconfig.json | 2 +- packages/localizations/tsconfig.json | 3 +- .../nextjs/src/app-beta/client/clerk-react.ts | 4 +- packages/nextjs/tsconfig.json | 2 +- packages/react/src/hooks/index.ts | 24 +++--- packages/react/tsconfig.json | 1 + packages/remix/tsconfig.json | 2 +- packages/sdk-node/tsconfig.json | 1 + packages/shared/tsconfig.json | 3 +- 20 files changed, 62 insertions(+), 83 deletions(-) diff --git a/package-lock.json b/package-lock.json index d2b2773023..57a2eeb70f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "ts-jest": "^29.0.3", "tsup": "^7.2.0", "turbo": "^1.10.15", - "typescript": "4.9.4", + "typescript": "^5.2.2", "zx": "^7.2.3" }, "engines": { @@ -2987,19 +2987,6 @@ "node": ">=8" } }, - "node_modules/@commitlint/load/node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/@commitlint/message": { "version": "17.4.2", "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-17.4.2.tgz", @@ -3247,19 +3234,16 @@ "stylis": "4.2.0" } }, - "node_modules/@emotion/babel-plugin/node_modules/stylis": { - "version": "4.2.0", - "license": "MIT" - }, "node_modules/@emotion/cache": { - "version": "11.10.5", - "license": "MIT", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.11.0.tgz", + "integrity": "sha512-P34z9ssTCBi3e9EI1ZsWpNHcfY1r09ZO0rZbRO2ob3ZQMnFI35jB536qoXbkdesr5EUhYi22anuEJuyxifaqAQ==", "dependencies": { - "@emotion/memoize": "^0.8.0", - "@emotion/sheet": "^1.2.1", - "@emotion/utils": "^1.2.0", - "@emotion/weak-memoize": "^0.3.0", - "stylis": "4.1.3" + "@emotion/memoize": "^0.8.1", + "@emotion/sheet": "^1.2.2", + "@emotion/utils": "^1.2.1", + "@emotion/weak-memoize": "^0.3.1", + "stylis": "4.2.0" } }, "node_modules/@emotion/css-prettifier": { @@ -3271,11 +3255,6 @@ "stylis": "4.2.0" } }, - "node_modules/@emotion/css-prettifier/node_modules/stylis": { - "version": "4.2.0", - "dev": true, - "license": "MIT" - }, "node_modules/@emotion/hash": { "version": "0.9.1", "license": "MIT" @@ -3357,11 +3336,6 @@ "node": ">=8" } }, - "node_modules/@emotion/jest/node_modules/stylis": { - "version": "4.2.0", - "dev": true, - "license": "MIT" - }, "node_modules/@emotion/jest/node_modules/supports-color": { "version": "7.2.0", "dev": true, @@ -3378,26 +3352,23 @@ "license": "MIT" }, "node_modules/@emotion/react": { - "version": "11.10.5", - "license": "MIT", + "version": "11.11.1", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.1.tgz", + "integrity": "sha512-5mlW1DquU5HaxjLkfkGN1GA/fvVGdyHURRiX/0FHl2cfIfRxSOfmxEH5YS43edp0OldZrZ+dkBKbngxcNCdZvA==", "dependencies": { "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.10.5", - "@emotion/cache": "^11.10.5", - "@emotion/serialize": "^1.1.1", - "@emotion/use-insertion-effect-with-fallbacks": "^1.0.0", - "@emotion/utils": "^1.2.0", - "@emotion/weak-memoize": "^0.3.0", + "@emotion/babel-plugin": "^11.11.0", + "@emotion/cache": "^11.11.0", + "@emotion/serialize": "^1.1.2", + "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", + "@emotion/utils": "^1.2.1", + "@emotion/weak-memoize": "^0.3.1", "hoist-non-react-statics": "^3.3.1" }, "peerDependencies": { - "@babel/core": "^7.0.0", "react": ">=16.8.0" }, "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, "@types/react": { "optional": true } @@ -27154,8 +27125,9 @@ } }, "node_modules/stylis": { - "version": "4.1.3", - "license": "MIT" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", + "integrity": "sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==" }, "node_modules/sucrase": { "version": "3.32.0", @@ -28535,15 +28507,16 @@ } }, "node_modules/typescript": { - "version": "4.9.4", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, - "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/ua-parser-js": { @@ -30262,8 +30235,8 @@ "@clerk/localizations": "1.26.4", "@clerk/shared": "0.24.4", "@clerk/types": "3.55.0", - "@emotion/cache": "11.10.5", - "@emotion/react": "11.10.5", + "@emotion/cache": "11.11.0", + "@emotion/react": "11.11.1", "@floating-ui/react": "0.25.4", "@zxcvbn-ts/core": "2.2.1", "@zxcvbn-ts/language-common": "3.0.2", diff --git a/package.json b/package.json index 157a35ca7f..76c85254ae 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "ts-jest": "^29.0.3", "tsup": "^7.2.0", "turbo": "^1.10.15", - "typescript": "4.9.4", + "typescript": "^5.2.2", "zx": "^7.2.3" }, "scripts": { diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index e41e9a0895..6c79dfa9a5 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -9,6 +9,7 @@ "forceConsistentCasingInFileNames": true, "importHelpers": true, "moduleResolution": "NodeNext", + "module": "NodeNext", "noImplicitReturns": true, "noUnusedLocals": false, "noUnusedParameters": true, diff --git a/packages/clerk-js/package.json b/packages/clerk-js/package.json index 623abb1296..a315fbe442 100644 --- a/packages/clerk-js/package.json +++ b/packages/clerk-js/package.json @@ -43,8 +43,8 @@ "@clerk/localizations": "1.26.4", "@clerk/shared": "0.24.4", "@clerk/types": "3.55.0", - "@emotion/cache": "11.10.5", - "@emotion/react": "11.10.5", + "@emotion/cache": "11.11.0", + "@emotion/react": "11.11.1", "@floating-ui/react": "0.25.4", "@zxcvbn-ts/core": "2.2.1", "@zxcvbn-ts/language-common": "3.0.2", diff --git a/packages/clerk-js/src/ui/elements/ArrowBlockButton.tsx b/packages/clerk-js/src/ui/elements/ArrowBlockButton.tsx index 696408c5ce..6f98aeed51 100644 --- a/packages/clerk-js/src/ui/elements/ArrowBlockButton.tsx +++ b/packages/clerk-js/src/ui/elements/ArrowBlockButton.tsx @@ -85,7 +85,7 @@ export const ArrowBlockButton = (props: ArrowBlockButtonProps) => { ({ color: theme.colors.$blackAlpha600, diff --git a/packages/clerk-js/src/ui/elements/IconButton.tsx b/packages/clerk-js/src/ui/elements/IconButton.tsx index b1bfb4e518..22469982aa 100644 --- a/packages/clerk-js/src/ui/elements/IconButton.tsx +++ b/packages/clerk-js/src/ui/elements/IconButton.tsx @@ -20,7 +20,7 @@ export const IconButton = ( ) : ( ); diff --git a/packages/clerk-js/src/ui/styledSystem/types.ts b/packages/clerk-js/src/ui/styledSystem/types.ts index 14496171f3..082f6ab0e1 100644 --- a/packages/clerk-js/src/ui/styledSystem/types.ts +++ b/packages/clerk-js/src/ui/styledSystem/types.ts @@ -13,7 +13,7 @@ type StyleRule = Exclude<_Interpolation, string | number | boolea type ThemableCssProp = ((params: InternalTheme) => StyleRule) | StyleRule; type CssProp = { css?: ThemableCssProp }; -export type AsProp = { as?: React.ElementType }; +export type AsProp = { as?: React.ElementType | undefined }; type ElementProps = { div: React.JSX.IntrinsicElements['div']; diff --git a/packages/clerk-js/tsconfig.declarations.json b/packages/clerk-js/tsconfig.declarations.json index 0312a6a03f..4d6f28ad16 100644 --- a/packages/clerk-js/tsconfig.declarations.json +++ b/packages/clerk-js/tsconfig.declarations.json @@ -8,6 +8,7 @@ "declarationMap": false, "sourceMap": false, "outDir": "./dist", - "declarationDir": "./dist/types" + "declarationDir": "./dist/types", + "noImplicitReturns": false } } diff --git a/packages/clerk-js/tsconfig.json b/packages/clerk-js/tsconfig.json index 0c6639918a..25ce7d1f40 100644 --- a/packages/clerk-js/tsconfig.json +++ b/packages/clerk-js/tsconfig.json @@ -7,13 +7,12 @@ "isolatedModules": true, "module": "esnext", "lib": ["es2021.intl"], - "moduleResolution": "NodeNext", + "moduleResolution": "Bundler", "noEmit": true, "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, - "resolveJsonModule": true, "sourceMap": false, "strict": true, "target": "ES2019", diff --git a/packages/expo/tsconfig.json b/packages/expo/tsconfig.json index 650f0cf2ee..d423ec1c4a 100644 --- a/packages/expo/tsconfig.json +++ b/packages/expo/tsconfig.json @@ -4,7 +4,7 @@ "baseUrl": ".", "lib": ["es6", "dom"], "jsx": "react", - "module": "commonjs", + "module": "NodeNext", "moduleResolution": "NodeNext", "importHelpers": true, "declaration": true, diff --git a/packages/fastify/tsconfig.json b/packages/fastify/tsconfig.json index 36221e05f4..f06061d1ec 100644 --- a/packages/fastify/tsconfig.json +++ b/packages/fastify/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "moduleResolution": "NodeNext", + "module": "NodeNext", "sourceMap": false, "strict": true, "esModuleInterop": true, diff --git a/packages/gatsby-plugin-clerk/tsconfig.json b/packages/gatsby-plugin-clerk/tsconfig.json index 650f0cf2ee..d423ec1c4a 100644 --- a/packages/gatsby-plugin-clerk/tsconfig.json +++ b/packages/gatsby-plugin-clerk/tsconfig.json @@ -4,7 +4,7 @@ "baseUrl": ".", "lib": ["es6", "dom"], "jsx": "react", - "module": "commonjs", + "module": "NodeNext", "moduleResolution": "NodeNext", "importHelpers": true, "declaration": true, diff --git a/packages/localizations/tsconfig.json b/packages/localizations/tsconfig.json index bb28a737e0..5020342437 100644 --- a/packages/localizations/tsconfig.json +++ b/packages/localizations/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { - "moduleResolution": "node", + "moduleResolution": "NodeNext", + "module": "NodeNext", "sourceMap": false, "strict": true, "esModuleInterop": true, diff --git a/packages/nextjs/src/app-beta/client/clerk-react.ts b/packages/nextjs/src/app-beta/client/clerk-react.ts index bae3acab59..38710d2af7 100644 --- a/packages/nextjs/src/app-beta/client/clerk-react.ts +++ b/packages/nextjs/src/app-beta/client/clerk-react.ts @@ -54,12 +54,12 @@ export const useEmailLink = _useEmailLink; * @deprecated Use imports from `@clerk/nextjs` instead. * For more details, consult the middleware documentation: https://clerk.com/docs/nextjs/middleware */ -export const useOrganization = _useOrganization; +export const useOrganization: typeof _useOrganization = _useOrganization; /** * @deprecated Use imports from `@clerk/nextjs` instead. * For more details, consult the middleware documentation: https://clerk.com/docs/nextjs/middleware */ -export const useOrganizationList = _useOrganizationList; +export const useOrganizationList: typeof _useOrganizationList = _useOrganizationList; /** * @deprecated Use imports from `@clerk/nextjs` instead. * For more details, consult the middleware documentation: https://clerk.com/docs/nextjs/middleware diff --git a/packages/nextjs/tsconfig.json b/packages/nextjs/tsconfig.json index 8bdd1fea4c..f0d8acec46 100644 --- a/packages/nextjs/tsconfig.json +++ b/packages/nextjs/tsconfig.json @@ -9,7 +9,7 @@ "isolatedModules": true, "jsx": "react", "lib": ["es6", "dom"], - "module": "commonjs", + "module": "NodeNext", "moduleResolution": "NodeNext", "noImplicitReturns": true, "noUnusedLocals": true, diff --git a/packages/react/src/hooks/index.ts b/packages/react/src/hooks/index.ts index bdbb220379..7b1f97f9e0 100644 --- a/packages/react/src/hooks/index.ts +++ b/packages/react/src/hooks/index.ts @@ -1,12 +1,12 @@ -export * from './useUser'; -export * from './useAuth'; -export * from './useSession'; -export * from './useClerk'; -export * from './useSignIn'; -export * from './useSignUp'; -export * from './useSessionList'; -export * from './useOrganization'; -export * from './useOrganizationList'; -export * from './useOrganizations'; -export * from './useMagicLink'; -export * from './useEmailLink'; +export { useUser } from './useUser'; +export { useAuth } from './useAuth'; +export { useSession } from './useSession'; +export { useClerk } from './useClerk'; +export { useSignIn } from './useSignIn'; +export { useSignUp } from './useSignUp'; +export { useSessionList } from './useSessionList'; +export { useOrganization } from './useOrganization'; +export { useOrganizationList } from './useOrganizationList'; +export { useOrganizations } from './useOrganizations'; +export { useMagicLink } from './useMagicLink'; +export { useEmailLink } from './useEmailLink'; diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index a66008741d..be04afbdc5 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -9,6 +9,7 @@ "jsx": "react", "lib": ["es6", "dom"], "moduleResolution": "NodeNext", + "module": "NodeNext", "noImplicitReturns": true, "noUnusedLocals": false, "noUnusedParameters": true, diff --git a/packages/remix/tsconfig.json b/packages/remix/tsconfig.json index 650f0cf2ee..d423ec1c4a 100644 --- a/packages/remix/tsconfig.json +++ b/packages/remix/tsconfig.json @@ -4,7 +4,7 @@ "baseUrl": ".", "lib": ["es6", "dom"], "jsx": "react", - "module": "commonjs", + "module": "NodeNext", "moduleResolution": "NodeNext", "importHelpers": true, "declaration": true, diff --git a/packages/sdk-node/tsconfig.json b/packages/sdk-node/tsconfig.json index ae3cbe23da..81ebb93d55 100644 --- a/packages/sdk-node/tsconfig.json +++ b/packages/sdk-node/tsconfig.json @@ -7,6 +7,7 @@ "importHelpers": true, "isolatedModules": true, "moduleResolution": "NodeNext", + "module": "NodeNext", "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, diff --git a/packages/shared/tsconfig.json b/packages/shared/tsconfig.json index 153c24097f..ef183915a6 100644 --- a/packages/shared/tsconfig.json +++ b/packages/shared/tsconfig.json @@ -4,7 +4,8 @@ "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, - "moduleResolution": "node", + "moduleResolution": "Bundler", + "module": "ESNext", "preserveWatchOutput": true, "skipLibCheck": true, "strict": true, From 8734a60af80edc3e3c4a720c57791461c5da3474 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 17 Oct 2023 09:52:13 +0200 Subject: [PATCH 41/53] fix(clerk-sdk-node): Remove incorrect type key in package.json --- packages/sdk-node/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/sdk-node/package.json b/packages/sdk-node/package.json index cbc9132cfa..80a743b2eb 100644 --- a/packages/sdk-node/package.json +++ b/packages/sdk-node/package.json @@ -1,7 +1,7 @@ { + "name": "@clerk/clerk-sdk-node", "version": "4.12.13", "license": "MIT", - "type": "commonjs", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.mjs", "types": "./dist/types/index.d.ts", @@ -46,7 +46,6 @@ "test": "jest", "test:ci": "jest --maxWorkers=70%" }, - "name": "@clerk/clerk-sdk-node", "author": { "name": "Clerk, Inc.", "email": "support@clerk.com", From d7d3a3997f62559369a86df6d13a55059fc553f1 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 17 Oct 2023 10:29:19 +0200 Subject: [PATCH 42/53] chore(backend): Fix tests --- packages/backend/src/runtime/index.ts | 4 ++-- packages/backend/tsconfig.test.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/runtime/index.ts b/packages/backend/src/runtime/index.ts index 7636f93eb0..f77338cb6d 100644 --- a/packages/backend/src/runtime/index.ts +++ b/packages/backend/src/runtime/index.ts @@ -12,9 +12,9 @@ * TODO: Support TS runtime modules */ -// @ts-expect-error +// @ts-ignore - These are package subpaths import crypto from '#crypto'; -// @ts-expect-error +// @ts-ignore - These are package subpaths import * as fetchApisPolyfill from '#fetch'; const { diff --git a/packages/backend/tsconfig.test.json b/packages/backend/tsconfig.test.json index f3c144d470..00f83413c7 100644 --- a/packages/backend/tsconfig.test.json +++ b/packages/backend/tsconfig.test.json @@ -3,8 +3,8 @@ "compilerOptions": { "allowSyntheticDefaultImports": true, "emitDeclarationOnly": false, - "module": "ES2022", - "moduleResolution": "Node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "noImplicitAny": false, "outDir": "./tests/dist", "target": "ES2020" From e15af40ae77de44527e64b746bf3e27ad9b8ab45 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 17 Oct 2023 10:50:16 +0200 Subject: [PATCH 43/53] chore(shared): Provide better backwards comp --- packages/shared/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/shared/package.json b/packages/shared/package.json index 9da1891be1..9171cf1b55 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -6,6 +6,8 @@ "files": [ "dist" ], + "main": "./dist/index.js", + "module": "./dist/index.mjs", "exports": { ".": { "import": { From bed6b727e40dee48d8011dcdecd9b45863e8a22f Mon Sep 17 00:00:00 2001 From: Lennart Date: Tue, 17 Oct 2023 11:01:20 +0200 Subject: [PATCH 44/53] Create wild-carrots-reply.md --- .changeset/wild-carrots-reply.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wild-carrots-reply.md diff --git a/.changeset/wild-carrots-reply.md b/.changeset/wild-carrots-reply.md new file mode 100644 index 0000000000..866556df65 --- /dev/null +++ b/.changeset/wild-carrots-reply.md @@ -0,0 +1,5 @@ +--- +"@clerk/shared": minor +--- + +TODO From 7855fdc1ba7ff21752bfca52e8885bdc8105e1c4 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 17 Oct 2023 11:26:43 +0200 Subject: [PATCH 45/53] chore(clerk-js): Typo fix --- packages/clerk-js/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/clerk-js/tsconfig.json b/packages/clerk-js/tsconfig.json index 25ce7d1f40..feaf686475 100644 --- a/packages/clerk-js/tsconfig.json +++ b/packages/clerk-js/tsconfig.json @@ -13,6 +13,7 @@ "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, + "resolveJsonModule": true, "sourceMap": false, "strict": true, "target": "ES2019", From f6ba951c41487a137434a50cc6875c90d9ff90b0 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 17 Oct 2023 13:13:55 +0200 Subject: [PATCH 46/53] lol --- packages/backend/tsconfig.test.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/backend/tsconfig.test.json b/packages/backend/tsconfig.test.json index 00f83413c7..c1959296aa 100644 --- a/packages/backend/tsconfig.test.json +++ b/packages/backend/tsconfig.test.json @@ -3,11 +3,14 @@ "compilerOptions": { "allowSyntheticDefaultImports": true, "emitDeclarationOnly": false, - "module": "NodeNext", - "moduleResolution": "NodeNext", + "module": "ES2022", + "moduleResolution": "Node", "noImplicitAny": false, "outDir": "./tests/dist", - "target": "ES2020" + "target": "ES2020", + "paths": { + "@clerk/shared/*": ["../shared/dist/*.js"] + } }, "include": ["src/**/*.test.ts"], "exclude": ["node_modules", "dist", "src/__tests__"] From 552195d17fc82f0c8e89975e29398718a8e64398 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 17 Oct 2023 13:59:25 +0200 Subject: [PATCH 47/53] chore(shared): Use "bundle: true" --- packages/shared/src/react/clerk-swr.ts | 2 +- packages/shared/tsup.config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/react/clerk-swr.ts b/packages/shared/src/react/clerk-swr.ts index 060ecc6865..11aedf73c0 100644 --- a/packages/shared/src/react/clerk-swr.ts +++ b/packages/shared/src/react/clerk-swr.ts @@ -1,4 +1,4 @@ 'use client'; export * from 'swr'; -export { default as useSWR } from 'swr'; +export { default as useSWR, SWRConfig } from 'swr'; export { default as useSWRInfinite } from 'swr/infinite'; diff --git a/packages/shared/tsup.config.ts b/packages/shared/tsup.config.ts index 11ee9555a7..591982aee7 100644 --- a/packages/shared/tsup.config.ts +++ b/packages/shared/tsup.config.ts @@ -11,7 +11,7 @@ export default defineConfig(overrideOptions => { return { entry: ['./src/**/*.{ts,tsx}', '!./src/**/*.test.{ts,tsx}'], format: ['cjs', 'esm'], - bundle: false, + bundle: true, clean: true, minify: false, sourcemap: true, From 626b336a25541acf59eda9c05d1731406c6967ee Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 17 Oct 2023 14:26:42 +0200 Subject: [PATCH 48/53] chore(repo): Update lock file --- package-lock.json | 98 +++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4f0b27f186..a7ca31b48c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32473,11 +32473,11 @@ }, "packages/backend": { "name": "@clerk/backend", - "version": "0.31.0", + "version": "0.31.1", "license": "MIT", "dependencies": { - "@clerk/shared": "0.24.4", - "@clerk/types": "3.55.0", + "@clerk/shared": "0.24.5", + "@clerk/types": "3.56.0", "@peculiar/webcrypto": "1.4.1", "@types/node": "16.18.6", "cookie": "0.5.0", @@ -32518,11 +32518,11 @@ }, "packages/chrome-extension": { "name": "@clerk/chrome-extension", - "version": "0.4.7", + "version": "0.4.8", "license": "MIT", "dependencies": { - "@clerk/clerk-js": "4.61.0", - "@clerk/clerk-react": "4.26.4" + "@clerk/clerk-js": "4.62.0", + "@clerk/clerk-react": "4.26.5" }, "devDependencies": { "@types/chrome": "*", @@ -32538,12 +32538,12 @@ }, "packages/clerk-js": { "name": "@clerk/clerk-js", - "version": "4.61.0", + "version": "4.62.0", "license": "MIT", "dependencies": { - "@clerk/localizations": "1.26.4", - "@clerk/shared": "0.24.4", - "@clerk/types": "3.55.0", + "@clerk/localizations": "1.26.5", + "@clerk/shared": "0.24.5", + "@clerk/types": "3.56.0", "@emotion/cache": "11.11.0", "@emotion/react": "11.11.1", "@floating-ui/react": "0.25.4", @@ -32877,17 +32877,17 @@ }, "packages/expo": { "name": "@clerk/clerk-expo", - "version": "0.19.9", + "version": "0.19.10", "license": "MIT", "dependencies": { - "@clerk/clerk-js": "4.61.0", - "@clerk/clerk-react": "4.26.4", - "@clerk/shared": "0.24.4", + "@clerk/clerk-js": "4.62.0", + "@clerk/clerk-react": "4.26.5", + "@clerk/shared": "0.24.5", "base-64": "1.0.0", "react-native-url-polyfill": "2.0.0" }, "devDependencies": { - "@clerk/types": "^3.55.0", + "@clerk/types": "^3.56.0", "@types/base-64": "^1.0.0", "@types/node": "^16.11.55", "@types/react": "*", @@ -32908,12 +32908,12 @@ }, "packages/fastify": { "name": "@clerk/fastify", - "version": "0.6.14", + "version": "0.6.15", "license": "MIT", "dependencies": { - "@clerk/backend": "0.31.0", - "@clerk/shared": "0.24.4", - "@clerk/types": "3.55.0", + "@clerk/backend": "0.31.1", + "@clerk/shared": "0.24.5", + "@clerk/types": "3.56.0", "cookies": "0.8.0" }, "devDependencies": { @@ -32929,13 +32929,13 @@ } }, "packages/gatsby-plugin-clerk": { - "version": "4.4.15", + "version": "4.4.16", "license": "MIT", "dependencies": { - "@clerk/backend": "0.31.0", - "@clerk/clerk-react": "4.26.4", - "@clerk/clerk-sdk-node": "4.12.13", - "@clerk/types": "3.55.0", + "@clerk/backend": "0.31.1", + "@clerk/clerk-react": "4.26.5", + "@clerk/clerk-sdk-node": "4.12.14", + "@clerk/types": "3.56.0", "cookie": "0.5.0", "tslib": "2.4.1" }, @@ -32958,10 +32958,10 @@ }, "packages/localizations": { "name": "@clerk/localizations", - "version": "1.26.4", + "version": "1.26.5", "license": "MIT", "dependencies": { - "@clerk/types": "3.55.0" + "@clerk/types": "3.56.0" }, "devDependencies": { "tsup": "*", @@ -32976,14 +32976,14 @@ }, "packages/nextjs": { "name": "@clerk/nextjs", - "version": "4.25.4", + "version": "4.25.5", "license": "MIT", "dependencies": { - "@clerk/backend": "0.31.0", - "@clerk/clerk-react": "4.26.4", - "@clerk/clerk-sdk-node": "4.12.13", - "@clerk/shared": "0.24.4", - "@clerk/types": "3.55.0", + "@clerk/backend": "0.31.1", + "@clerk/clerk-react": "4.26.5", + "@clerk/clerk-sdk-node": "4.12.14", + "@clerk/shared": "0.24.5", + "@clerk/types": "3.56.0", "path-to-regexp": "6.2.1", "tslib": "2.4.1" }, @@ -33015,11 +33015,11 @@ }, "packages/react": { "name": "@clerk/clerk-react", - "version": "4.26.4", + "version": "4.26.5", "license": "MIT", "dependencies": { - "@clerk/shared": "0.24.4", - "@clerk/types": "3.55.0", + "@clerk/shared": "0.24.5", + "@clerk/types": "3.56.0", "tslib": "2.4.1" }, "devDependencies": { @@ -33041,13 +33041,13 @@ }, "packages/remix": { "name": "@clerk/remix", - "version": "3.0.6", + "version": "3.0.7", "license": "MIT", "dependencies": { - "@clerk/backend": "0.31.0", - "@clerk/clerk-react": "4.26.4", - "@clerk/shared": "0.24.4", - "@clerk/types": "3.55.0", + "@clerk/backend": "0.31.1", + "@clerk/clerk-react": "4.26.5", + "@clerk/shared": "0.24.5", + "@clerk/types": "3.56.0", "cookie": "0.5.0", "tslib": "2.4.1" }, @@ -33076,12 +33076,12 @@ }, "packages/sdk-node": { "name": "@clerk/clerk-sdk-node", - "version": "4.12.13", + "version": "4.12.14", "license": "MIT", "dependencies": { - "@clerk/backend": "0.31.0", - "@clerk/shared": "0.24.4", - "@clerk/types": "3.55.0", + "@clerk/backend": "0.31.1", + "@clerk/shared": "0.24.5", + "@clerk/types": "3.56.0", "@types/cookies": "0.7.7", "@types/express": "4.17.14", "@types/node-fetch": "2.6.2", @@ -33117,7 +33117,7 @@ }, "packages/shared": { "name": "@clerk/shared", - "version": "0.24.4", + "version": "0.24.5", "license": "MIT", "dependencies": { "glob-to-regexp": "0.4.1", @@ -33125,7 +33125,7 @@ "swr": "2.2.0" }, "devDependencies": { - "@clerk/types": "3.55.0", + "@clerk/types": "3.56.0", "@types/glob-to-regexp": "0.4.1", "@types/js-cookie": "3.0.2", "tsup": "*", @@ -33142,10 +33142,10 @@ }, "packages/themes": { "name": "@clerk/themes", - "version": "1.7.7", + "version": "1.7.8", "license": "MIT", "devDependencies": { - "@clerk/types": "3.55.0", + "@clerk/types": "3.56.0", "typescript": "*" }, "engines": { @@ -33157,7 +33157,7 @@ }, "packages/types": { "name": "@clerk/types", - "version": "3.55.0", + "version": "3.56.0", "license": "MIT", "dependencies": { "csstype": "3.1.1" From 0fbb88f19e33aa6ac9b95bf9a1735f1b556b9a8c Mon Sep 17 00:00:00 2001 From: LekoArts Date: Tue, 17 Oct 2023 14:57:25 +0200 Subject: [PATCH 49/53] chore(shared): Move react/hooks into react --- packages/clerk-js/src/ui/Components.tsx | 2 +- .../clerk-js/src/ui/contexts/CoreClientContext.tsx | 3 +-- .../src/ui/contexts/CoreOrganizationContext.tsx | 3 +-- .../clerk-js/src/ui/contexts/CoreSessionContext.tsx | 3 +-- packages/clerk-js/src/ui/contexts/CoreUserContext.tsx | 3 +-- .../src/ui/customizables/AppearanceContext.tsx | 2 +- packages/clerk-js/src/ui/elements/Form.tsx | 2 +- packages/clerk-js/src/ui/elements/Menu.tsx | 2 +- packages/clerk-js/src/ui/elements/Modal.tsx | 2 +- packages/clerk-js/src/ui/elements/Navbar.tsx | 2 +- packages/clerk-js/src/ui/elements/Select.tsx | 2 +- packages/clerk-js/src/ui/elements/Tabs.tsx | 2 +- packages/clerk-js/src/ui/elements/TimerButton.tsx | 2 +- .../src/ui/elements/contexts/CardStateContext.tsx | 2 +- .../src/ui/elements/contexts/FlowMetadataContext.tsx | 2 +- .../src/ui/primitives/hooks/useFormControl.tsx | 2 +- packages/react/src/contexts/AuthContext.ts | 2 +- packages/react/src/hooks/useOrganization.ts | 2 +- packages/react/src/hooks/useOrganizationList.ts | 2 +- packages/react/src/hooks/useOrganizations.ts | 2 +- packages/shared/package.json | 10 ---------- packages/shared/src/react/index.ts | 2 ++ 22 files changed, 22 insertions(+), 34 deletions(-) diff --git a/packages/clerk-js/src/ui/Components.tsx b/packages/clerk-js/src/ui/Components.tsx index 7d9a1f966a..c21c106eed 100644 --- a/packages/clerk-js/src/ui/Components.tsx +++ b/packages/clerk-js/src/ui/Components.tsx @@ -1,5 +1,5 @@ import { createDeferredPromise } from '@clerk/shared'; -import { useSafeLayoutEffect } from '@clerk/shared/react/hooks'; +import { useSafeLayoutEffect } from '@clerk/shared/react'; import type { Appearance, Clerk, diff --git a/packages/clerk-js/src/ui/contexts/CoreClientContext.tsx b/packages/clerk-js/src/ui/contexts/CoreClientContext.tsx index 044b5dce09..b0d5ad7a42 100644 --- a/packages/clerk-js/src/ui/contexts/CoreClientContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreClientContext.tsx @@ -1,5 +1,4 @@ -import { ClientContext, useClientContext } from '@clerk/shared/react'; -import { assertContextExists } from '@clerk/shared/react/hooks'; +import { assertContextExists, ClientContext, useClientContext } from '@clerk/shared/react'; import type { SessionResource, SignInResource, SignUpResource } from '@clerk/types'; export const CoreClientContext = ClientContext; diff --git a/packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx b/packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx index 095124728b..5f093f521f 100644 --- a/packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreOrganizationContext.tsx @@ -1,5 +1,4 @@ -import { OrganizationProvider } from '@clerk/shared/react'; -import { useOrganization, useOrganizationList, useOrganizations } from '@clerk/shared/react/hooks'; +import { OrganizationProvider, useOrganization, useOrganizationList, useOrganizations } from '@clerk/shared/react'; export const CoreOrganizationProvider = OrganizationProvider; export const useCoreOrganization = useOrganization; diff --git a/packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx b/packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx index 386cc64c3e..3cd86e17c6 100644 --- a/packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreSessionContext.tsx @@ -1,5 +1,4 @@ -import { SessionContext, useSessionContext } from '@clerk/shared/react'; -import { assertContextExists } from '@clerk/shared/react/hooks'; +import { assertContextExists, SessionContext, useSessionContext } from '@clerk/shared/react'; import type { SessionResource } from '@clerk/types'; import React from 'react'; diff --git a/packages/clerk-js/src/ui/contexts/CoreUserContext.tsx b/packages/clerk-js/src/ui/contexts/CoreUserContext.tsx index 6b8a7b8639..6936128b80 100644 --- a/packages/clerk-js/src/ui/contexts/CoreUserContext.tsx +++ b/packages/clerk-js/src/ui/contexts/CoreUserContext.tsx @@ -1,5 +1,4 @@ -import { UserContext, useUserContext } from '@clerk/shared/react'; -import { assertContextExists } from '@clerk/shared/react/hooks'; +import { assertContextExists, UserContext, useUserContext } from '@clerk/shared/react'; import React, { useContext } from 'react'; import { clerkCoreErrorUserIsNotDefined } from '../../core/errors'; diff --git a/packages/clerk-js/src/ui/customizables/AppearanceContext.tsx b/packages/clerk-js/src/ui/customizables/AppearanceContext.tsx index d1afa4f81e..201edc9cab 100644 --- a/packages/clerk-js/src/ui/customizables/AppearanceContext.tsx +++ b/packages/clerk-js/src/ui/customizables/AppearanceContext.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import React from 'react'; import { useDeepEqualMemo } from '../hooks'; diff --git a/packages/clerk-js/src/ui/elements/Form.tsx b/packages/clerk-js/src/ui/elements/Form.tsx index b35531fbef..012b02482b 100644 --- a/packages/clerk-js/src/ui/elements/Form.tsx +++ b/packages/clerk-js/src/ui/elements/Form.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import type { FieldId } from '@clerk/types'; import React, { useState } from 'react'; diff --git a/packages/clerk-js/src/ui/elements/Menu.tsx b/packages/clerk-js/src/ui/elements/Menu.tsx index 51d61e3ab0..4d6f2f64bd 100644 --- a/packages/clerk-js/src/ui/elements/Menu.tsx +++ b/packages/clerk-js/src/ui/elements/Menu.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import type { MenuId } from '@clerk/types'; import type { PropsWithChildren } from 'react'; import React, { cloneElement, isValidElement, useLayoutEffect, useRef } from 'react'; diff --git a/packages/clerk-js/src/ui/elements/Modal.tsx b/packages/clerk-js/src/ui/elements/Modal.tsx index 212e5fa4c9..290351a471 100644 --- a/packages/clerk-js/src/ui/elements/Modal.tsx +++ b/packages/clerk-js/src/ui/elements/Modal.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook, useSafeLayoutEffect } from '@clerk/shared/react/hooks'; +import { createContextAndHook, useSafeLayoutEffect } from '@clerk/shared/react'; import React, { useRef } from 'react'; import { descriptors, Flex } from '../customizables'; diff --git a/packages/clerk-js/src/ui/elements/Navbar.tsx b/packages/clerk-js/src/ui/elements/Navbar.tsx index ee34a52a2d..4f348f2c4d 100644 --- a/packages/clerk-js/src/ui/elements/Navbar.tsx +++ b/packages/clerk-js/src/ui/elements/Navbar.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook, useSafeLayoutEffect } from '@clerk/shared/react/hooks'; +import { createContextAndHook, useSafeLayoutEffect } from '@clerk/shared/react'; import type { NavbarItemId } from '@clerk/types'; import React, { useEffect } from 'react'; diff --git a/packages/clerk-js/src/ui/elements/Select.tsx b/packages/clerk-js/src/ui/elements/Select.tsx index 8816be07df..52813e4f4f 100644 --- a/packages/clerk-js/src/ui/elements/Select.tsx +++ b/packages/clerk-js/src/ui/elements/Select.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import type { SelectId } from '@clerk/types'; import type { PropsWithChildren, ReactElement } from 'react'; import React, { useState } from 'react'; diff --git a/packages/clerk-js/src/ui/elements/Tabs.tsx b/packages/clerk-js/src/ui/elements/Tabs.tsx index 005d0740ca..4b38e24482 100644 --- a/packages/clerk-js/src/ui/elements/Tabs.tsx +++ b/packages/clerk-js/src/ui/elements/Tabs.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import type { PropsWithChildren } from 'react'; import React from 'react'; diff --git a/packages/clerk-js/src/ui/elements/TimerButton.tsx b/packages/clerk-js/src/ui/elements/TimerButton.tsx index 7b390e233d..eebcb538cf 100644 --- a/packages/clerk-js/src/ui/elements/TimerButton.tsx +++ b/packages/clerk-js/src/ui/elements/TimerButton.tsx @@ -1,4 +1,4 @@ -import { useSafeLayoutEffect } from '@clerk/shared/react/hooks'; +import { useSafeLayoutEffect } from '@clerk/shared/react'; import React, { useEffect } from 'react'; import { Button, useLocalizations } from '../customizables'; diff --git a/packages/clerk-js/src/ui/elements/contexts/CardStateContext.tsx b/packages/clerk-js/src/ui/elements/contexts/CardStateContext.tsx index 2d95792196..2c9d1096c0 100644 --- a/packages/clerk-js/src/ui/elements/contexts/CardStateContext.tsx +++ b/packages/clerk-js/src/ui/elements/contexts/CardStateContext.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import type { ClerkAPIError, ClerkRuntimeError } from '@clerk/types'; import React from 'react'; diff --git a/packages/clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx b/packages/clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx index 191f747767..35bcd088af 100644 --- a/packages/clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx +++ b/packages/clerk-js/src/ui/elements/contexts/FlowMetadataContext.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import React from 'react'; type FlowMetadata = { diff --git a/packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx b/packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx index 06d559a017..0fb370722f 100644 --- a/packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx +++ b/packages/clerk-js/src/ui/primitives/hooks/useFormControl.tsx @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import type { ClerkAPIError } from '@clerk/types'; import React from 'react'; diff --git a/packages/react/src/contexts/AuthContext.ts b/packages/react/src/contexts/AuthContext.ts index c6d9f6292b..ce346388e4 100644 --- a/packages/react/src/contexts/AuthContext.ts +++ b/packages/react/src/contexts/AuthContext.ts @@ -1,4 +1,4 @@ -import { createContextAndHook } from '@clerk/shared/react/hooks'; +import { createContextAndHook } from '@clerk/shared/react'; import type { ActJWTClaim, MembershipRole } from '@clerk/types'; export const [AuthContext, useAuthContext] = createContextAndHook<{ diff --git a/packages/react/src/hooks/useOrganization.ts b/packages/react/src/hooks/useOrganization.ts index 34547dfd33..0cf70872ec 100644 --- a/packages/react/src/hooks/useOrganization.ts +++ b/packages/react/src/hooks/useOrganization.ts @@ -1 +1 @@ -export { useOrganization } from '@clerk/shared/react/hooks'; +export { useOrganization } from '@clerk/shared/react'; diff --git a/packages/react/src/hooks/useOrganizationList.ts b/packages/react/src/hooks/useOrganizationList.ts index 362fd40f6e..905ba6b1e5 100644 --- a/packages/react/src/hooks/useOrganizationList.ts +++ b/packages/react/src/hooks/useOrganizationList.ts @@ -1 +1 @@ -export { useOrganizationList } from '@clerk/shared/react/hooks'; +export { useOrganizationList } from '@clerk/shared/react'; diff --git a/packages/react/src/hooks/useOrganizations.ts b/packages/react/src/hooks/useOrganizations.ts index ee84bbea08..1f25e6ba3b 100644 --- a/packages/react/src/hooks/useOrganizations.ts +++ b/packages/react/src/hooks/useOrganizations.ts @@ -1 +1 @@ -export { useOrganizations } from '@clerk/shared/react/hooks'; +export { useOrganizations } from '@clerk/shared/react'; diff --git a/packages/shared/package.json b/packages/shared/package.json index fbee739fe4..8ad069f940 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -38,16 +38,6 @@ "types": "./dist/react/index.d.ts", "default": "./dist/react/index.js" } - }, - "./react/hooks": { - "import": { - "types": "./dist/react/hooks/index.d.mts", - "default": "./dist/react/hooks/index.mjs" - }, - "require": { - "types": "./dist/react/hooks/index.d.ts", - "default": "./dist/react/hooks/index.js" - } } }, "scripts": { diff --git a/packages/shared/src/react/index.ts b/packages/shared/src/react/index.ts index e22d53ca69..f1c1afd549 100644 --- a/packages/shared/src/react/index.ts +++ b/packages/shared/src/react/index.ts @@ -1,3 +1,5 @@ +export * from './hooks'; + export { ClerkInstanceContext, ClientContext, From 7847fcd25a44c339b9ace3fad1ad0e9287bcd36a Mon Sep 17 00:00:00 2001 From: Lennart Date: Tue, 17 Oct 2023 14:58:54 +0200 Subject: [PATCH 50/53] Update wild-carrots-reply.md --- .changeset/wild-carrots-reply.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/wild-carrots-reply.md b/.changeset/wild-carrots-reply.md index 866556df65..b38fa66e7b 100644 --- a/.changeset/wild-carrots-reply.md +++ b/.changeset/wild-carrots-reply.md @@ -1,5 +1,5 @@ --- -"@clerk/shared": minor +"@clerk/shared": major --- TODO From f9232b317d27e3eb3e91967845d42f5fbb5db46f Mon Sep 17 00:00:00 2001 From: LekoArts Date: Wed, 18 Oct 2023 09:16:25 +0200 Subject: [PATCH 51/53] fix(shared): Use correct entries for tsup --- packages/shared/tsup.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/tsup.config.ts b/packages/shared/tsup.config.ts index 591982aee7..8c912b55a0 100644 --- a/packages/shared/tsup.config.ts +++ b/packages/shared/tsup.config.ts @@ -9,7 +9,7 @@ export default defineConfig(overrideOptions => { const isWatch = !!overrideOptions.watch; return { - entry: ['./src/**/*.{ts,tsx}', '!./src/**/*.test.{ts,tsx}'], + entry: ['./src/*.{ts,tsx}', './src/react/index.ts', '!./src/**/*.test.{ts,tsx}'], format: ['cjs', 'esm'], bundle: true, clean: true, From e6bf6f8953dee57da73ed04c4c876731c3a2592f Mon Sep 17 00:00:00 2001 From: LekoArts Date: Wed, 18 Oct 2023 10:19:47 +0200 Subject: [PATCH 52/53] chore(repo): Add changelog entry --- .changeset/wild-carrots-reply.md | 58 +++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/.changeset/wild-carrots-reply.md b/.changeset/wild-carrots-reply.md index b38fa66e7b..fabaf13958 100644 --- a/.changeset/wild-carrots-reply.md +++ b/.changeset/wild-carrots-reply.md @@ -2,4 +2,60 @@ "@clerk/shared": major --- -TODO +The package was reworked to allow for better isomorphic use cases and ESM support, resulting in some breaking changes. It now allows for [subpath exports](https://nodejs.org/api/packages.html#subpath-exports) and restricts some imports to specific subpaths. + +Instead of importing from the root `@clerk/shared` import you can now use subpaths for most things: + +```diff +- import { deprecated, OrganizationProvider } from "@clerk/shared" ++ import { deprecated } from "@clerk/shared/deprecated" ++ import { OrganizationProvider } from "@clerk/shared/react" +``` + +By using subpaths you can tell bundlers to only bundle specific parts, potentially helping with tree-shaking. It also mitigates issues where e.g. modules only relevant for React where picked up in Node.js-only environments. + +If you're not using `@clerk/shared` directly (only by proxy through e.g. `@clerk/clerk-react`) you don't need to do anything. If you are relying on `@clerk/shared`, please read through the breaking changes below and change your code accordingly. You can rely on your IDE to give you hints on which exports are available at `@clerk/shared` and `@clerk/shared/` subpaths. + +**Breaking Changes** + +- `@clerk/shared` was and still is a dual CJS/ESM package. The ESM files provided by `@clerk/shared` now use `.mjs` file extensions and also define them in their import paths, following the ESM spec. Your bundler should handle this for you. +- Some imports where moved from the root `@clerk/shared` import to isolated subpaths. + - Helper utils for cookies and globs: + + ```diff + - import { createCookieHandler, globs } from "@clerk/shared" + + import { createCookieHandler } from "@clerk/shared/cookie" + + import { globs } from "@clerk/shared/globs" + ``` + - Everything related to React. Below is a small example and the full list of exports: + + ```diff + - import { useSafeLayoutEffect, ClerkInstanceContext } from "@clerk/shared" + + import { useSafeLayoutEffect, ClerkInstanceContext } from "@clerk/shared/react" + ``` + + Full list of exports moved to `@clerk/shared/react`: + + ```ts + export { + ClerkInstanceContext, + ClientContext, + OrganizationContext, + OrganizationProvider, + SessionContext, + UserContext, + assertContextExists, + createContextAndHook, + useClerkInstanceContext, + useClientContext, + useOrganization, + useOrganizationContext, + useOrganizationList, + useOrganizations, + useSafeLayoutEffect, + useSessionContext, + useUserContext + } + ``` + +If you run into an issues that might be a bug, please [open a bug report](https://github.com/clerkinc/javascript/issues/new?assignees=&labels=needs-triage&projects=&template=BUG_REPORT.yml) with a minimal reproduction. From 6b4e081045d168f22eb1cee5e67431e91a0d7b19 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Wed, 18 Oct 2023 13:46:43 +0200 Subject: [PATCH 53/53] chore(clerk-js): Add comment --- packages/clerk-js/webpack.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/clerk-js/webpack.config.js b/packages/clerk-js/webpack.config.js index ee9226b37e..54ad82f7dc 100644 --- a/packages/clerk-js/webpack.config.js +++ b/packages/clerk-js/webpack.config.js @@ -29,6 +29,8 @@ const common = ({ mode }) => { return { mode, resolve: { + // Attempt to resolve these extensions in order + // @see https://webpack.js.org/configuration/resolve/#resolveextensions extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'], }, plugins: [