@dynamic-labs/logger 2.1.0-alpha.2 → 2.1.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +170 -0
- package/_virtual/_tslib.cjs +36 -0
- package/_virtual/_tslib.js +32 -0
- package/package.json +4 -1
- package/src/index.cjs +128 -22
- package/src/index.d.ts +13 -9
- package/src/index.js +108 -9
- package/src/types.cjs +13 -0
- package/src/types.d.ts +13 -0
- package/src/types.js +11 -0
- package/src/utils/deepMerge.cjs +57 -0
- package/src/utils/deepMerge.d.ts +1 -0
- package/src/utils/deepMerge.js +53 -0
- package/src/utils/processArgs.cjs +21 -0
- package/src/utils/processArgs.d.ts +10 -0
- package/src/utils/processArgs.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,174 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.1.0-alpha.21](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.20...v2.1.0-alpha.21) (2024-05-21)
|
|
3
|
+
|
|
4
|
+
## [2.1.0-alpha.20](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.19...v2.1.0-alpha.20) (2024-05-21)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* adds client.networks module ([#5650](https://github.com/dynamic-labs/DynamicAuth/issues/5650)) ([70f7fe5](https://github.com/dynamic-labs/DynamicAuth/commit/70f7fe5f437756c51e787ac12183be0a23c51b89))
|
|
10
|
+
* user fields supports custom fields ([#5639](https://github.com/dynamic-labs/DynamicAuth/issues/5639)) ([8eb5788](https://github.com/dynamic-labs/DynamicAuth/commit/8eb5788fc3e1286929f5949ecb57736b21b13fb5))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* add webcredentials to expo ([#5640](https://github.com/dynamic-labs/DynamicAuth/issues/5640)) ([9026fbf](https://github.com/dynamic-labs/DynamicAuth/commit/9026fbf0108537e884588f3adcdb9f0db04a159b))
|
|
16
|
+
* init ethers web3provider without a network if selected network is unsupported ([#5651](https://github.com/dynamic-labs/DynamicAuth/issues/5651)) ([e82040f](https://github.com/dynamic-labs/DynamicAuth/commit/e82040f424b17a70fac4400ab5b85a0dc6c0e35a))
|
|
17
|
+
|
|
18
|
+
## [2.1.0-alpha.19](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.18...v2.1.0-alpha.19) (2024-05-17)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* add createUserProfileFromSDKUser ([#5596](https://github.com/dynamic-labs/DynamicAuth/issues/5596)) ([d37a1b4](https://github.com/dynamic-labs/DynamicAuth/commit/d37a1b4119f5ff4fff1e987d157f6d5abf105a8b))
|
|
24
|
+
* add headless social sign-in ([#5439](https://github.com/dynamic-labs/DynamicAuth/issues/5439)) ([e32fdf8](https://github.com/dynamic-labs/DynamicAuth/commit/e32fdf863718d661b90b592c8df734e92386ddf3))
|
|
25
|
+
* fetch custom fields in profile and update user ([#5627](https://github.com/dynamic-labs/DynamicAuth/issues/5627)) ([3940c25](https://github.com/dynamic-labs/DynamicAuth/commit/3940c2542bb330f3ed9a8eb98eed9d05c8fcb03a))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* include applinks details to AASA ([#5635](https://github.com/dynamic-labs/DynamicAuth/issues/5635)) ([ce94fec](https://github.com/dynamic-labs/DynamicAuth/commit/ce94fec80adbb3eb4efcb79d1aa2cc6eb35eab6f))
|
|
31
|
+
* include the appOrigin to every api call to create correct passkey ([#5636](https://github.com/dynamic-labs/DynamicAuth/issues/5636)) ([ee64df3](https://github.com/dynamic-labs/DynamicAuth/commit/ee64df3b90037bd29cca161e601973ef202c58f0))
|
|
32
|
+
* use PromptModal when using the DynamicMultiWalletPromptsWidget for pending connection views ([#5594](https://github.com/dynamic-labs/DynamicAuth/issues/5594)) ([c095b6e](https://github.com/dynamic-labs/DynamicAuth/commit/c095b6e4c974f02cfe632963be92d16bb201dfa5))
|
|
33
|
+
|
|
34
|
+
## [2.1.0-alpha.18](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.17...v2.1.0-alpha.18) (2024-05-15)
|
|
35
|
+
|
|
36
|
+
## [2.1.0-alpha.17](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.16...v2.1.0-alpha.17) (2024-05-15)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
* add coinbaseWalletPreference prop ([#5607](https://github.com/dynamic-labs/DynamicAuth/issues/5607)) ([1ac3b2c](https://github.com/dynamic-labs/DynamicAuth/commit/1ac3b2ce7abb136465f4aa88b045dfb70d99aad7))
|
|
42
|
+
|
|
43
|
+
## [2.1.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.15...v2.1.0-alpha.16) (2024-05-14)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
* add client.sdk.error with errors from the webview ([#5520](https://github.com/dynamic-labs/DynamicAuth/issues/5520)) ([a886927](https://github.com/dynamic-labs/DynamicAuth/commit/a8869273bf361c870d6e3cb82a28d9ccec65905b))
|
|
49
|
+
* add setDefaultTabIndex to default the selected wallets tab ([#5593](https://github.com/dynamic-labs/DynamicAuth/issues/5593)) ([6e8ce05](https://github.com/dynamic-labs/DynamicAuth/commit/6e8ce053c4f6f009acc57dac55a8e9c74fbcc73b))
|
|
50
|
+
* add visibility/auth-flow/user-profile to react-native ([#5564](https://github.com/dynamic-labs/DynamicAuth/issues/5564)) ([d93cea8](https://github.com/dynamic-labs/DynamicAuth/commit/d93cea82a123c6ec4d3d594a7dc064f4db2981c2))
|
|
51
|
+
|
|
52
|
+
## [2.1.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.14...v2.1.0-alpha.15) (2024-05-13)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Bug Fixes
|
|
56
|
+
|
|
57
|
+
* when a pregen is created, primaryWallet is not being setup ([#5584](https://github.com/dynamic-labs/DynamicAuth/issues/5584)) ([de08721](https://github.com/dynamic-labs/DynamicAuth/commit/de0872151e09f91dcbfaf1d043cf830f9df8d799))
|
|
58
|
+
|
|
59
|
+
## [2.1.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.13...v2.1.0-alpha.14) (2024-05-09)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Features
|
|
63
|
+
|
|
64
|
+
* add useSwitchWallet ([#5575](https://github.com/dynamic-labs/DynamicAuth/issues/5575)) ([d3053d9](https://github.com/dynamic-labs/DynamicAuth/commit/d3053d920110c26ef8052e77bf59e07dedc7c683))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Bug Fixes
|
|
68
|
+
|
|
69
|
+
* linking phantom wallets in mobile ([#5524](https://github.com/dynamic-labs/DynamicAuth/issues/5524)) ([28d90f5](https://github.com/dynamic-labs/DynamicAuth/commit/28d90f5126b9c22535b63a3797cc060ef089fc63))
|
|
70
|
+
* only show farcaster QR code if Social Login is enabled ([#5559](https://github.com/dynamic-labs/DynamicAuth/issues/5559)) ([fa71aaf](https://github.com/dynamic-labs/DynamicAuth/commit/fa71aaf0f80da31d397600b2fd0cbea99b3689a4))
|
|
71
|
+
* remove goerli testnets and add sepolia ([#5565](https://github.com/dynamic-labs/DynamicAuth/issues/5565)) ([888eb03](https://github.com/dynamic-labs/DynamicAuth/commit/888eb031ef6f4dbbdc3015265cce8647d2c720b0))
|
|
72
|
+
|
|
73
|
+
## [2.1.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.12...v2.1.0-alpha.13) (2024-05-03)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Bug Fixes
|
|
77
|
+
|
|
78
|
+
* ensure Farcaster QR uses useSocialAuth hook ([#5550](https://github.com/dynamic-labs/DynamicAuth/issues/5550)) ([57fcd97](https://github.com/dynamic-labs/DynamicAuth/commit/57fcd97c44e3f52065dcf856acf7bca7b24fabc7))
|
|
79
|
+
|
|
80
|
+
## [2.1.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.11...v2.1.0-alpha.12) (2024-05-02)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Features
|
|
84
|
+
|
|
85
|
+
* display Farcaster QR code when it is the only login option ([#5514](https://github.com/dynamic-labs/DynamicAuth/issues/5514)) ([7b166d9](https://github.com/dynamic-labs/DynamicAuth/commit/7b166d9a30c581746f0e2edb71c44fc015dc128e))
|
|
86
|
+
|
|
87
|
+
## [2.1.0-alpha.11](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.10...v2.1.0-alpha.11) (2024-05-02)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### Features
|
|
91
|
+
|
|
92
|
+
* **GVTY-1050:** add account token balances hook ([#5521](https://github.com/dynamic-labs/DynamicAuth/issues/5521)) ([5a6f937](https://github.com/dynamic-labs/DynamicAuth/commit/5a6f93733019f3b8d5c7a2c7a5537172a1e7eba4))
|
|
93
|
+
* headless reveal embedded wallet key ([#5518](https://github.com/dynamic-labs/DynamicAuth/issues/5518)) ([77c1536](https://github.com/dynamic-labs/DynamicAuth/commit/77c15360b2b28c52cbdeafb3ce8ca7e80dbecf57))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Bug Fixes
|
|
97
|
+
|
|
98
|
+
* fallback to walletconnect for zerion on mobile ([#5536](https://github.com/dynamic-labs/DynamicAuth/issues/5536)) ([f0e5bfe](https://github.com/dynamic-labs/DynamicAuth/commit/f0e5bfea0b2ab271fd4c1475c8ce708ecb1a5926))
|
|
99
|
+
|
|
100
|
+
## [2.1.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.9...v2.1.0-alpha.10) (2024-04-30)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Features
|
|
104
|
+
|
|
105
|
+
* bump @coinbase/wallet-sdk to latest beta ([#5388](https://github.com/dynamic-labs/DynamicAuth/issues/5388)) ([9225546](https://github.com/dynamic-labs/DynamicAuth/commit/922554630ccf2ef98bc297521309918f922bc671))
|
|
106
|
+
|
|
107
|
+
## [2.1.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.8...v2.1.0-alpha.9) (2024-04-30)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### Features
|
|
111
|
+
|
|
112
|
+
* headless create embedded wallet with optional passkey data parameter ([#5487](https://github.com/dynamic-labs/DynamicAuth/issues/5487)) ([891c3d7](https://github.com/dynamic-labs/DynamicAuth/commit/891c3d77a02a019140bcb8dd03b62b1afd69710e))
|
|
113
|
+
|
|
114
|
+
## [2.1.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.7...v2.1.0-alpha.8) (2024-04-26)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
### Bug Fixes
|
|
118
|
+
|
|
119
|
+
* display wallet tabs when linking a wallet ([#5491](https://github.com/dynamic-labs/DynamicAuth/issues/5491)) ([10fd6b4](https://github.com/dynamic-labs/DynamicAuth/commit/10fd6b4d9aec7596338c50e17f79f6be534cf2c1))
|
|
120
|
+
* ensure zerodev viem client handles eth_accounts call ([#5477](https://github.com/dynamic-labs/DynamicAuth/issues/5477)) ([1132e1e](https://github.com/dynamic-labs/DynamicAuth/commit/1132e1e8655b58e81cb56789453ba56a059f52ec))
|
|
121
|
+
* network with keplr ([#5485](https://github.com/dynamic-labs/DynamicAuth/issues/5485)) ([b86f2fc](https://github.com/dynamic-labs/DynamicAuth/commit/b86f2fce491f9752e80a86643916da9ac7fb9276))
|
|
122
|
+
* refetch nameservice data and display properly ([#5476](https://github.com/dynamic-labs/DynamicAuth/issues/5476)) ([2aee798](https://github.com/dynamic-labs/DynamicAuth/commit/2aee798846f69496201bec7aa52e7ec1f370b7c3))
|
|
123
|
+
* use embeddedWallet create response authToken in embeddedWalletCreated ([#5478](https://github.com/dynamic-labs/DynamicAuth/issues/5478)) ([51772da](https://github.com/dynamic-labs/DynamicAuth/commit/51772daf557a72984c757efd8301e2b510dc37f1))
|
|
124
|
+
|
|
125
|
+
## [2.1.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.6...v2.1.0-alpha.7) (2024-04-25)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Bug Fixes
|
|
129
|
+
|
|
130
|
+
* restore embedded wallet session iframe element conflict ([#5474](https://github.com/dynamic-labs/DynamicAuth/issues/5474)) ([c157477](https://github.com/dynamic-labs/DynamicAuth/commit/c157477ea126b3130b13b711796bdd06215e7af1))
|
|
131
|
+
|
|
132
|
+
## [2.1.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.5...v2.1.0-alpha.6) (2024-04-24)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Bug Fixes
|
|
136
|
+
|
|
137
|
+
* embedded wallets headless session control fixes ([#5469](https://github.com/dynamic-labs/DynamicAuth/issues/5469)) ([92e6c35](https://github.com/dynamic-labs/DynamicAuth/commit/92e6c359d2710fd4f5f5a6fedc4acf6c4bab78ba))
|
|
138
|
+
|
|
139
|
+
## [2.1.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.4...v2.1.0-alpha.5) (2024-04-23)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
### Bug Fixes
|
|
143
|
+
|
|
144
|
+
* get embedded wallet checking the wrong chain enum ([#5458](https://github.com/dynamic-labs/DynamicAuth/issues/5458)) ([ed1c523](https://github.com/dynamic-labs/DynamicAuth/commit/ed1c523ca14cd4d21c00181ab40802f876c02b80))
|
|
145
|
+
|
|
146
|
+
## [2.1.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.3...v2.1.0-alpha.4) (2024-04-23)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### Features
|
|
150
|
+
|
|
151
|
+
* add email and sms to client auth module ([#5436](https://github.com/dynamic-labs/DynamicAuth/issues/5436)) ([5420476](https://github.com/dynamic-labs/DynamicAuth/commit/5420476d1ba38fd4f987f28e9aefbfb3e61ea2bf))
|
|
152
|
+
* headless create passkeys for embedded wallets ([#5395](https://github.com/dynamic-labs/DynamicAuth/issues/5395)) ([0b64099](https://github.com/dynamic-labs/DynamicAuth/commit/0b6409968457f65886248f0a0879e39ec3803fd0))
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
### Bug Fixes
|
|
156
|
+
|
|
157
|
+
* prevent wagmi from reconnect when DynamicContextProvider rerender ([#5446](https://github.com/dynamic-labs/DynamicAuth/issues/5446)) ([33337af](https://github.com/dynamic-labs/DynamicAuth/commit/33337af76786963cb3db7fa7c58c1292c529d0ac))
|
|
158
|
+
|
|
159
|
+
## [2.1.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.2...v2.1.0-alpha.3) (2024-04-23)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### Features
|
|
163
|
+
|
|
164
|
+
* add merge user accounts flow ([#5429](https://github.com/dynamic-labs/DynamicAuth/issues/5429)) ([41d4239](https://github.com/dynamic-labs/DynamicAuth/commit/41d423906625e28004ba8f20baf57847ed8bf5d0))
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
### Bug Fixes
|
|
168
|
+
|
|
169
|
+
* disconnect wallet on lock in connect-only ([#5422](https://github.com/dynamic-labs/DynamicAuth/issues/5422)) ([a26f9fe](https://github.com/dynamic-labs/DynamicAuth/commit/a26f9fe93cf8568f1482e10b831de98c77fb2a2d))
|
|
170
|
+
* useReactiveProxy to stop proxing when it finds a reactive value ([#5428](https://github.com/dynamic-labs/DynamicAuth/issues/5428)) ([838dce9](https://github.com/dynamic-labs/DynamicAuth/commit/838dce9ee953361e41772239a91adb1dd8d40234))
|
|
171
|
+
|
|
2
172
|
## [2.1.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.1...v2.1.0-alpha.2) (2024-04-19)
|
|
3
173
|
|
|
4
174
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
|
|
21
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
+
var e = new Error(message);
|
|
33
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.__awaiter = __awaiter;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
|
|
17
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
28
|
+
var e = new Error(message);
|
|
29
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { __awaiter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/logger",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.21",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -24,5 +24,8 @@
|
|
|
24
24
|
"require": "./src/index.cjs"
|
|
25
25
|
},
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"eventemitter3": "5.0.1"
|
|
27
30
|
}
|
|
28
31
|
}
|
package/src/index.cjs
CHANGED
|
@@ -3,28 +3,61 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
|
+
var EventEmitter = require('eventemitter3');
|
|
8
|
+
var types = require('./types.cjs');
|
|
9
|
+
var deepMerge = require('./utils/deepMerge.cjs');
|
|
10
|
+
var processArgs = require('./utils/processArgs.cjs');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
15
|
+
|
|
6
16
|
/* eslint-disable @typescript-eslint/no-explicit-any, no-console */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
10
|
-
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
11
|
-
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
12
|
-
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
13
|
-
LogLevel[LogLevel["MUTE"] = 99] = "MUTE";
|
|
14
|
-
})(exports.LogLevel || (exports.LogLevel = {}));
|
|
17
|
+
const IGNORE_MESSAGES = ['Failed to send logs to server'];
|
|
18
|
+
const messageQueue = [];
|
|
15
19
|
class Logger {
|
|
16
20
|
constructor(name, level) {
|
|
17
21
|
this.name = name;
|
|
22
|
+
this.meta = undefined;
|
|
18
23
|
if (level === undefined && process.env['NODE_ENV'] !== 'production') {
|
|
19
|
-
this.level =
|
|
24
|
+
this.level = types.LogLevel.DEBUG;
|
|
20
25
|
}
|
|
21
26
|
else if (level === undefined) {
|
|
22
|
-
this.level =
|
|
27
|
+
this.level = types.LogLevel.WARN;
|
|
23
28
|
}
|
|
24
29
|
else {
|
|
25
30
|
this.level = level;
|
|
26
31
|
}
|
|
27
32
|
}
|
|
33
|
+
static setEmitErrors(emit) {
|
|
34
|
+
if (emit !== undefined) {
|
|
35
|
+
Logger.globalKeys.emitErrors = emit;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
static setEnvironmentId(environmentId) {
|
|
39
|
+
if (environmentId !== undefined) {
|
|
40
|
+
Logger.globalKeys.environmentId = environmentId;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
setMetaData(key, value) {
|
|
44
|
+
if (!this.meta) {
|
|
45
|
+
this.meta = {};
|
|
46
|
+
}
|
|
47
|
+
const data = {};
|
|
48
|
+
key.split('.').reduce((acc, k, i, arr) => {
|
|
49
|
+
if (i === arr.length - 1) {
|
|
50
|
+
acc[k] = value;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
if (!acc[k]) {
|
|
54
|
+
acc[k] = {};
|
|
55
|
+
}
|
|
56
|
+
return acc[k];
|
|
57
|
+
}
|
|
58
|
+
}, data);
|
|
59
|
+
this.meta = deepMerge.deepMerge(this.meta, data);
|
|
60
|
+
}
|
|
28
61
|
getNameArray(name) {
|
|
29
62
|
return Array.isArray(name) ? name : [name];
|
|
30
63
|
}
|
|
@@ -32,13 +65,13 @@ class Logger {
|
|
|
32
65
|
return new Logger([...this.getNameArray(this.name), ...this.getNameArray(name)], level !== null && level !== void 0 ? level : this.level);
|
|
33
66
|
}
|
|
34
67
|
get logLevel() {
|
|
35
|
-
return
|
|
68
|
+
return types.LogLevel[this.level];
|
|
36
69
|
}
|
|
37
70
|
setLogLevel(level) {
|
|
38
|
-
if (level in
|
|
39
|
-
this.level =
|
|
71
|
+
if (level in types.LogLevel && typeof level === 'string') {
|
|
72
|
+
this.level = types.LogLevel[level];
|
|
40
73
|
}
|
|
41
|
-
else if (level in
|
|
74
|
+
else if (level in types.LogLevel && typeof level === 'number') {
|
|
42
75
|
this.level = level;
|
|
43
76
|
}
|
|
44
77
|
else {
|
|
@@ -59,36 +92,109 @@ class Logger {
|
|
|
59
92
|
message = JSON.stringify(message);
|
|
60
93
|
}
|
|
61
94
|
const names = (Array.isArray(this.name) ? this.name : [this.name]).map((name) => `[${name}]`);
|
|
62
|
-
return `${names.join('')} [${
|
|
95
|
+
return `${names.join('')} [${types.LogLevel[level]}]: ${message}`;
|
|
96
|
+
}
|
|
97
|
+
captureAndSend(level, message, ...args) {
|
|
98
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
if (Logger.globalKeys.emitErrors &&
|
|
100
|
+
!IGNORE_MESSAGES.includes(message === null || message === void 0 ? void 0 : message.toString()) &&
|
|
101
|
+
typeof window !== 'undefined') {
|
|
102
|
+
this.emitHttpLogs(level, message, ...args);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
emitHttpLogs(level, message, ...args) {
|
|
107
|
+
messageQueue.push({ args, level, message });
|
|
108
|
+
if (messageQueue.length === 1) {
|
|
109
|
+
/**
|
|
110
|
+
* Batching the logs to send them in a single request
|
|
111
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide#batching_operations
|
|
112
|
+
*
|
|
113
|
+
* Essentially, multiple calls to log in the same event loop will be batched into a single request
|
|
114
|
+
*/
|
|
115
|
+
queueMicrotask(() => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
const messages = [];
|
|
118
|
+
messageQueue.forEach((msg) => {
|
|
119
|
+
var _a, _b, _c, _d, _e;
|
|
120
|
+
const body = {};
|
|
121
|
+
const { objectArgs, remainingArgs } = processArgs.processArgs(msg);
|
|
122
|
+
Object.assign(body, ...objectArgs);
|
|
123
|
+
Object.assign(body, {
|
|
124
|
+
level: types.LogLevel[msg.level],
|
|
125
|
+
message: [msg.message, ...remainingArgs].join(' '),
|
|
126
|
+
meta: this.meta,
|
|
127
|
+
url: {
|
|
128
|
+
hostname: (_a = window.location) === null || _a === void 0 ? void 0 : _a.hostname,
|
|
129
|
+
origin: (_b = window.location) === null || _b === void 0 ? void 0 : _b.origin,
|
|
130
|
+
pathname: (_c = window.location) === null || _c === void 0 ? void 0 : _c.pathname,
|
|
131
|
+
port: (_d = window.location) === null || _d === void 0 ? void 0 : _d.port,
|
|
132
|
+
protocol: (_e = window.location) === null || _e === void 0 ? void 0 : _e.protocol,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
messages.push(body);
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
if (!((_a = Logger.globalKeys) === null || _a === void 0 ? void 0 : _a.environmentId)) {
|
|
139
|
+
throw new Error('Environment ID not set');
|
|
140
|
+
}
|
|
141
|
+
yield fetch(`https://logs.dynamicauth.com/api/v1/${(_b = Logger.globalKeys) === null || _b === void 0 ? void 0 : _b.environmentId}`, {
|
|
142
|
+
body: JSON.stringify(messages),
|
|
143
|
+
headers: {
|
|
144
|
+
'Content-Type': 'application/json',
|
|
145
|
+
},
|
|
146
|
+
method: 'POST',
|
|
147
|
+
mode: 'cors',
|
|
148
|
+
referrerPolicy: 'origin-when-cross-origin',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
this.debug('Failed to send logs to server', error);
|
|
153
|
+
}
|
|
154
|
+
messageQueue.length = 0;
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
63
157
|
}
|
|
64
158
|
log(level, message, ...args) {
|
|
65
|
-
if (level < this.level || level ===
|
|
159
|
+
if (level < this.level || level === types.LogLevel.MUTE) {
|
|
66
160
|
return;
|
|
67
161
|
}
|
|
68
162
|
const fmtMsg = this.formatMessage(level, message);
|
|
69
163
|
switch (level) {
|
|
70
|
-
case
|
|
164
|
+
case types.LogLevel.WARN:
|
|
71
165
|
console.warn(fmtMsg, ...args);
|
|
72
166
|
break;
|
|
73
|
-
case
|
|
167
|
+
case types.LogLevel.ERROR:
|
|
74
168
|
console.error(fmtMsg, ...args);
|
|
75
169
|
break;
|
|
76
170
|
default:
|
|
77
171
|
console.log(fmtMsg, ...args);
|
|
78
172
|
}
|
|
173
|
+
if (level === types.LogLevel.ERROR) {
|
|
174
|
+
this.captureAndSend(level, message, ...args);
|
|
175
|
+
}
|
|
79
176
|
}
|
|
80
177
|
debug(message, ...args) {
|
|
81
|
-
this.log(
|
|
178
|
+
this.log(types.LogLevel.DEBUG, message, ...args);
|
|
82
179
|
}
|
|
83
180
|
info(message, ...args) {
|
|
84
|
-
this.log(
|
|
181
|
+
this.log(types.LogLevel.INFO, message, ...args);
|
|
85
182
|
}
|
|
86
183
|
warn(message, ...args) {
|
|
87
|
-
this.log(
|
|
184
|
+
this.log(types.LogLevel.WARN, message, ...args);
|
|
88
185
|
}
|
|
89
186
|
error(message, ...args) {
|
|
90
|
-
|
|
187
|
+
Logger.events.emit('error', message);
|
|
188
|
+
this.log(types.LogLevel.ERROR, message, ...args);
|
|
91
189
|
}
|
|
92
190
|
}
|
|
191
|
+
Logger.globalKeys = {
|
|
192
|
+
emitErrors: true,
|
|
193
|
+
};
|
|
194
|
+
Logger.events = new EventEmitter__default["default"]();
|
|
93
195
|
|
|
196
|
+
Object.defineProperty(exports, 'LogLevel', {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: function () { return types.LogLevel; }
|
|
199
|
+
});
|
|
94
200
|
exports.Logger = Logger;
|
package/src/index.d.ts
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
WARN = 2,
|
|
5
|
-
ERROR = 3,
|
|
6
|
-
MUTE = 99
|
|
7
|
-
}
|
|
8
|
-
type Message = string | Error | unknown;
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { LogLevel, Message } from './types';
|
|
3
|
+
export { LogLevel } from './types';
|
|
9
4
|
export declare class Logger {
|
|
10
5
|
private name;
|
|
11
6
|
private level;
|
|
7
|
+
private static globalKeys;
|
|
8
|
+
private meta;
|
|
12
9
|
constructor(name: string | string[], level?: LogLevel);
|
|
10
|
+
static setEmitErrors(emit?: boolean): void;
|
|
11
|
+
static setEnvironmentId(environmentId?: string): void;
|
|
12
|
+
static events: EventEmitter<{
|
|
13
|
+
error: Message;
|
|
14
|
+
}, any>;
|
|
15
|
+
setMetaData(key: string, value: any): void;
|
|
13
16
|
private getNameArray;
|
|
14
17
|
createLogger(name: string | string[], level?: LogLevel): Logger;
|
|
15
18
|
get logLevel(): string;
|
|
16
19
|
setLogLevel(level: LogLevel | keyof typeof LogLevel): void;
|
|
17
20
|
private formatMessage;
|
|
21
|
+
private captureAndSend;
|
|
22
|
+
private emitHttpLogs;
|
|
18
23
|
log(level: LogLevel, message: Message, ...args: any[]): void;
|
|
19
24
|
debug(message: Message, ...args: any[]): void;
|
|
20
25
|
info(message: Message, ...args: any[]): void;
|
|
21
26
|
warn(message: Message, ...args: any[]): void;
|
|
22
27
|
error(message: Message, ...args: any[]): void;
|
|
23
28
|
}
|
|
24
|
-
export {};
|
package/src/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
|
+
import { LogLevel } from './types.js';
|
|
5
|
+
export { LogLevel } from './types.js';
|
|
6
|
+
import { deepMerge } from './utils/deepMerge.js';
|
|
7
|
+
import { processArgs } from './utils/processArgs.js';
|
|
8
|
+
|
|
2
9
|
/* eslint-disable @typescript-eslint/no-explicit-any, no-console */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
6
|
-
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
7
|
-
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
8
|
-
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
9
|
-
LogLevel[LogLevel["MUTE"] = 99] = "MUTE";
|
|
10
|
-
})(LogLevel || (LogLevel = {}));
|
|
10
|
+
const IGNORE_MESSAGES = ['Failed to send logs to server'];
|
|
11
|
+
const messageQueue = [];
|
|
11
12
|
class Logger {
|
|
12
13
|
constructor(name, level) {
|
|
13
14
|
this.name = name;
|
|
15
|
+
this.meta = undefined;
|
|
14
16
|
if (level === undefined && process.env['NODE_ENV'] !== 'production') {
|
|
15
17
|
this.level = LogLevel.DEBUG;
|
|
16
18
|
}
|
|
@@ -21,6 +23,34 @@ class Logger {
|
|
|
21
23
|
this.level = level;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
26
|
+
static setEmitErrors(emit) {
|
|
27
|
+
if (emit !== undefined) {
|
|
28
|
+
Logger.globalKeys.emitErrors = emit;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
static setEnvironmentId(environmentId) {
|
|
32
|
+
if (environmentId !== undefined) {
|
|
33
|
+
Logger.globalKeys.environmentId = environmentId;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
setMetaData(key, value) {
|
|
37
|
+
if (!this.meta) {
|
|
38
|
+
this.meta = {};
|
|
39
|
+
}
|
|
40
|
+
const data = {};
|
|
41
|
+
key.split('.').reduce((acc, k, i, arr) => {
|
|
42
|
+
if (i === arr.length - 1) {
|
|
43
|
+
acc[k] = value;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (!acc[k]) {
|
|
47
|
+
acc[k] = {};
|
|
48
|
+
}
|
|
49
|
+
return acc[k];
|
|
50
|
+
}
|
|
51
|
+
}, data);
|
|
52
|
+
this.meta = deepMerge(this.meta, data);
|
|
53
|
+
}
|
|
24
54
|
getNameArray(name) {
|
|
25
55
|
return Array.isArray(name) ? name : [name];
|
|
26
56
|
}
|
|
@@ -57,6 +87,67 @@ class Logger {
|
|
|
57
87
|
const names = (Array.isArray(this.name) ? this.name : [this.name]).map((name) => `[${name}]`);
|
|
58
88
|
return `${names.join('')} [${LogLevel[level]}]: ${message}`;
|
|
59
89
|
}
|
|
90
|
+
captureAndSend(level, message, ...args) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
if (Logger.globalKeys.emitErrors &&
|
|
93
|
+
!IGNORE_MESSAGES.includes(message === null || message === void 0 ? void 0 : message.toString()) &&
|
|
94
|
+
typeof window !== 'undefined') {
|
|
95
|
+
this.emitHttpLogs(level, message, ...args);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
emitHttpLogs(level, message, ...args) {
|
|
100
|
+
messageQueue.push({ args, level, message });
|
|
101
|
+
if (messageQueue.length === 1) {
|
|
102
|
+
/**
|
|
103
|
+
* Batching the logs to send them in a single request
|
|
104
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide#batching_operations
|
|
105
|
+
*
|
|
106
|
+
* Essentially, multiple calls to log in the same event loop will be batched into a single request
|
|
107
|
+
*/
|
|
108
|
+
queueMicrotask(() => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
const messages = [];
|
|
111
|
+
messageQueue.forEach((msg) => {
|
|
112
|
+
var _a, _b, _c, _d, _e;
|
|
113
|
+
const body = {};
|
|
114
|
+
const { objectArgs, remainingArgs } = processArgs(msg);
|
|
115
|
+
Object.assign(body, ...objectArgs);
|
|
116
|
+
Object.assign(body, {
|
|
117
|
+
level: LogLevel[msg.level],
|
|
118
|
+
message: [msg.message, ...remainingArgs].join(' '),
|
|
119
|
+
meta: this.meta,
|
|
120
|
+
url: {
|
|
121
|
+
hostname: (_a = window.location) === null || _a === void 0 ? void 0 : _a.hostname,
|
|
122
|
+
origin: (_b = window.location) === null || _b === void 0 ? void 0 : _b.origin,
|
|
123
|
+
pathname: (_c = window.location) === null || _c === void 0 ? void 0 : _c.pathname,
|
|
124
|
+
port: (_d = window.location) === null || _d === void 0 ? void 0 : _d.port,
|
|
125
|
+
protocol: (_e = window.location) === null || _e === void 0 ? void 0 : _e.protocol,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
messages.push(body);
|
|
129
|
+
});
|
|
130
|
+
try {
|
|
131
|
+
if (!((_a = Logger.globalKeys) === null || _a === void 0 ? void 0 : _a.environmentId)) {
|
|
132
|
+
throw new Error('Environment ID not set');
|
|
133
|
+
}
|
|
134
|
+
yield fetch(`https://logs.dynamicauth.com/api/v1/${(_b = Logger.globalKeys) === null || _b === void 0 ? void 0 : _b.environmentId}`, {
|
|
135
|
+
body: JSON.stringify(messages),
|
|
136
|
+
headers: {
|
|
137
|
+
'Content-Type': 'application/json',
|
|
138
|
+
},
|
|
139
|
+
method: 'POST',
|
|
140
|
+
mode: 'cors',
|
|
141
|
+
referrerPolicy: 'origin-when-cross-origin',
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
this.debug('Failed to send logs to server', error);
|
|
146
|
+
}
|
|
147
|
+
messageQueue.length = 0;
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
60
151
|
log(level, message, ...args) {
|
|
61
152
|
if (level < this.level || level === LogLevel.MUTE) {
|
|
62
153
|
return;
|
|
@@ -72,6 +163,9 @@ class Logger {
|
|
|
72
163
|
default:
|
|
73
164
|
console.log(fmtMsg, ...args);
|
|
74
165
|
}
|
|
166
|
+
if (level === LogLevel.ERROR) {
|
|
167
|
+
this.captureAndSend(level, message, ...args);
|
|
168
|
+
}
|
|
75
169
|
}
|
|
76
170
|
debug(message, ...args) {
|
|
77
171
|
this.log(LogLevel.DEBUG, message, ...args);
|
|
@@ -83,8 +177,13 @@ class Logger {
|
|
|
83
177
|
this.log(LogLevel.WARN, message, ...args);
|
|
84
178
|
}
|
|
85
179
|
error(message, ...args) {
|
|
180
|
+
Logger.events.emit('error', message);
|
|
86
181
|
this.log(LogLevel.ERROR, message, ...args);
|
|
87
182
|
}
|
|
88
183
|
}
|
|
184
|
+
Logger.globalKeys = {
|
|
185
|
+
emitErrors: true,
|
|
186
|
+
};
|
|
187
|
+
Logger.events = new EventEmitter();
|
|
89
188
|
|
|
90
|
-
export {
|
|
189
|
+
export { Logger };
|
package/src/types.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
exports.LogLevel = void 0;
|
|
7
|
+
(function (LogLevel) {
|
|
8
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
9
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
10
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
11
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
12
|
+
LogLevel[LogLevel["MUTE"] = 99] = "MUTE";
|
|
13
|
+
})(exports.LogLevel || (exports.LogLevel = {}));
|
package/src/types.d.ts
ADDED
package/src/types.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
var LogLevel;
|
|
3
|
+
(function (LogLevel) {
|
|
4
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
5
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
6
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
7
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
8
|
+
LogLevel[LogLevel["MUTE"] = 99] = "MUTE";
|
|
9
|
+
})(LogLevel || (LogLevel = {}));
|
|
10
|
+
|
|
11
|
+
export { LogLevel };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const deepMerge = (obj1, obj2) => {
|
|
7
|
+
if (typeof obj1 !== 'object' || typeof obj2 !== 'object') {
|
|
8
|
+
// If either obj1 or obj2 is not an object, return obj1
|
|
9
|
+
return obj2;
|
|
10
|
+
}
|
|
11
|
+
// Create a new object to store the merged result
|
|
12
|
+
const result = Object.assign({}, obj1);
|
|
13
|
+
for (const key in obj2) {
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key)) {
|
|
15
|
+
if (typeof obj2[key] === 'object' &&
|
|
16
|
+
Object.prototype.hasOwnProperty.call(obj1, key) &&
|
|
17
|
+
typeof obj1[key] === 'object') {
|
|
18
|
+
// If both obj1 and obj2 have objects with the same key, recursively merge them
|
|
19
|
+
result[key] = deepMerge(obj1[key], obj2[key]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// Otherwise, simply assign the value from obj2 to the result
|
|
23
|
+
result[key] = obj2[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
// Example usage:
|
|
30
|
+
//
|
|
31
|
+
// const obj1 = {
|
|
32
|
+
// a: 1,
|
|
33
|
+
// b: {
|
|
34
|
+
// c: 2,
|
|
35
|
+
// d: 3,
|
|
36
|
+
// },
|
|
37
|
+
// };
|
|
38
|
+
//
|
|
39
|
+
// const obj2 = {
|
|
40
|
+
// a: 4,
|
|
41
|
+
// b: {
|
|
42
|
+
// c: 5,
|
|
43
|
+
// },
|
|
44
|
+
// e: 6,
|
|
45
|
+
// };
|
|
46
|
+
//
|
|
47
|
+
// const result = {
|
|
48
|
+
// a: 4,
|
|
49
|
+
// b: {
|
|
50
|
+
// c: 5,
|
|
51
|
+
// d: 3,
|
|
52
|
+
// },
|
|
53
|
+
// e: 6,
|
|
54
|
+
// };
|
|
55
|
+
//
|
|
56
|
+
|
|
57
|
+
exports.deepMerge = deepMerge;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deepMerge: <T>(obj1: any, obj2: any) => T;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const deepMerge = (obj1, obj2) => {
|
|
3
|
+
if (typeof obj1 !== 'object' || typeof obj2 !== 'object') {
|
|
4
|
+
// If either obj1 or obj2 is not an object, return obj1
|
|
5
|
+
return obj2;
|
|
6
|
+
}
|
|
7
|
+
// Create a new object to store the merged result
|
|
8
|
+
const result = Object.assign({}, obj1);
|
|
9
|
+
for (const key in obj2) {
|
|
10
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key)) {
|
|
11
|
+
if (typeof obj2[key] === 'object' &&
|
|
12
|
+
Object.prototype.hasOwnProperty.call(obj1, key) &&
|
|
13
|
+
typeof obj1[key] === 'object') {
|
|
14
|
+
// If both obj1 and obj2 have objects with the same key, recursively merge them
|
|
15
|
+
result[key] = deepMerge(obj1[key], obj2[key]);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// Otherwise, simply assign the value from obj2 to the result
|
|
19
|
+
result[key] = obj2[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
// Example usage:
|
|
26
|
+
//
|
|
27
|
+
// const obj1 = {
|
|
28
|
+
// a: 1,
|
|
29
|
+
// b: {
|
|
30
|
+
// c: 2,
|
|
31
|
+
// d: 3,
|
|
32
|
+
// },
|
|
33
|
+
// };
|
|
34
|
+
//
|
|
35
|
+
// const obj2 = {
|
|
36
|
+
// a: 4,
|
|
37
|
+
// b: {
|
|
38
|
+
// c: 5,
|
|
39
|
+
// },
|
|
40
|
+
// e: 6,
|
|
41
|
+
// };
|
|
42
|
+
//
|
|
43
|
+
// const result = {
|
|
44
|
+
// a: 4,
|
|
45
|
+
// b: {
|
|
46
|
+
// c: 5,
|
|
47
|
+
// d: 3,
|
|
48
|
+
// },
|
|
49
|
+
// e: 6,
|
|
50
|
+
// };
|
|
51
|
+
//
|
|
52
|
+
|
|
53
|
+
export { deepMerge };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Split args into object and non-object args
|
|
8
|
+
* @param message
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
const processArgs = (message) => {
|
|
12
|
+
// Apply object args to body
|
|
13
|
+
const objectArgs = message.args.filter((arg) => typeof arg === 'object');
|
|
14
|
+
// Capture remaining non-object args
|
|
15
|
+
const remainingArgs = message.args
|
|
16
|
+
.filter((arg) => typeof arg !== 'object' || arg instanceof Error)
|
|
17
|
+
.map((arg) => arg.toString());
|
|
18
|
+
return { objectArgs, remainingArgs };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.processArgs = processArgs;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Split args into object and non-object args
|
|
4
|
+
* @param message
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
const processArgs = (message) => {
|
|
8
|
+
// Apply object args to body
|
|
9
|
+
const objectArgs = message.args.filter((arg) => typeof arg === 'object');
|
|
10
|
+
// Capture remaining non-object args
|
|
11
|
+
const remainingArgs = message.args
|
|
12
|
+
.filter((arg) => typeof arg !== 'object' || arg instanceof Error)
|
|
13
|
+
.map((arg) => arg.toString());
|
|
14
|
+
return { objectArgs, remainingArgs };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { processArgs };
|