forked from rango-exchange/rango-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/next' into next
- Loading branch information
Showing
211 changed files
with
3,915 additions
and
6,925 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
dist/ | ||
lerna-debug.log | ||
.vercel | ||
.npmrc | ||
|
||
# i18n | ||
translations/**/*.ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yarn commitlint $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Enforce to use yarn | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Configuration = { | ||
extends: ['@commitlint/config-conventional'], | ||
}; | ||
|
||
module.exports = Configuration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "@rango-dev/logging-console", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"type": "module", | ||
"source": "./src/index.ts", | ||
"main": "./dist/index.js", | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"dependencies": { | ||
"@rango-dev/logging-types": "^0.1.0" | ||
}, | ||
"scripts": { | ||
"build": "node ../../scripts/build/command.mjs --path logging/console", | ||
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json", | ||
"clean": "rimraf dist", | ||
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'", | ||
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { EventPayload } from '@rango-dev/logging-types'; | ||
|
||
import { Level } from '@rango-dev/logging-types'; | ||
|
||
export function levelToName(level: Level) { | ||
switch (level) { | ||
case Level.Trace: | ||
return 'trace'; | ||
case Level.Debug: | ||
return 'debug'; | ||
case Level.Info: | ||
return 'info'; | ||
case Level.Warn: | ||
return 'warn'; | ||
case Level.Error: | ||
return 'error'; | ||
case Level.Off: | ||
return 'off'; | ||
default: | ||
return `unknown level (${level})`; | ||
} | ||
} | ||
|
||
export function levelToConsoleStyle(level: Level) { | ||
switch (level) { | ||
case Level.Trace: | ||
return 'background-color: #87d9ff; color: #000000;'; | ||
case Level.Debug: | ||
return 'background-color: #4fff00; color: #000000;'; | ||
case Level.Info: | ||
return 'background-color: #ffd800; color: #000000;'; | ||
case Level.Warn: | ||
return 'background-color: #0034ff; color: #000000;'; | ||
case Level.Error: | ||
return 'background-color: #ff0000;'; | ||
case Level.Off: | ||
return 'background-color: #000000;'; | ||
default: | ||
return 'background-color: #cccccc;'; | ||
} | ||
} | ||
|
||
export function formatMessage(payload: EventPayload) { | ||
return [ | ||
`%c[%s] %O %O`, | ||
levelToConsoleStyle(payload.level), | ||
levelToName(payload.level), | ||
payload.message, | ||
payload.data, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { layer } from './layer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Layer } from '@rango-dev/logging-types'; | ||
|
||
import { Level } from '@rango-dev/logging-types'; | ||
|
||
import { formatMessage } from './helpers'; | ||
|
||
export function layer(): Layer { | ||
return { | ||
handler(payload) { | ||
const message = formatMessage(payload); | ||
|
||
switch (payload.level) { | ||
case Level.Trace: | ||
console.debug(...message); | ||
break; | ||
case Level.Debug: | ||
console.debug(...message); | ||
break; | ||
case Level.Info: | ||
console.log(...message); | ||
break; | ||
case Level.Warn: | ||
console.warn(...message); | ||
break; | ||
case Level.Error: | ||
console.error(...message); | ||
break; | ||
default: | ||
console.log(...message); | ||
break; | ||
} | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs | ||
"extends": "../../tsconfig.lib.json", | ||
"include": ["src", "types"], | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "./src", | ||
"lib": ["dom", "esnext"] | ||
// match output dir to input dir. e.g. dist/index instead of dist/src/index | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "@rango-dev/logging-core", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"type": "module", | ||
"source": "./src/index.ts", | ||
"main": "./dist/index.js", | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"dependencies": { | ||
"@rango-dev/logging-types": "^0.1.0" | ||
}, | ||
"scripts": { | ||
"build": "node ../../scripts/build/command.mjs --path logging/core", | ||
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json", | ||
"clean": "rimraf dist", | ||
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'", | ||
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function isValidInstance(error: unknown) { | ||
return error instanceof Error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { error, warn, info, debug, trace, ev } from './logging'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { Data, EventPayload, Message } from '@rango-dev/logging-types'; | ||
|
||
import { EventType, Level } from '@rango-dev/logging-types'; | ||
|
||
import { isValidInstance } from './helpers'; | ||
|
||
export function ev(level: Level, message: Message, data?: Data) { | ||
if (!isValidInstance(message)) { | ||
throw new Error('Your error input should be an instance of Error.'); | ||
} | ||
|
||
const event = new CustomEvent<EventPayload>(EventType, { | ||
detail: { | ||
level, | ||
message, | ||
data, | ||
}, | ||
}); | ||
|
||
if (!document) { | ||
console.warn("document isn't available."); | ||
} else { | ||
document.dispatchEvent(event); | ||
} | ||
} | ||
|
||
export function error(message: Message, data?: Data) { | ||
ev(Level.Error, message, data); | ||
} | ||
|
||
export function warn(message: Message, data?: Data) { | ||
ev(Level.Warn, message, data); | ||
} | ||
export function info(message: Message, data?: Data) { | ||
ev(Level.Info, message, data); | ||
} | ||
|
||
export function debug(message: Message, data?: Data) { | ||
ev(Level.Debug, message, data); | ||
} | ||
|
||
export function trace(message: Message, data?: Data) { | ||
ev(Level.Trace, message, data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs | ||
"extends": "../../tsconfig.lib.json", | ||
"include": ["src", "types"], | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "./src", | ||
"lib": ["dom", "esnext"] | ||
// match output dir to input dir. e.g. dist/index instead of dist/src/index | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## How it works? | ||
|
||
Take a look at original PR: | ||
https://github.com/rango-exchange/rango-client/pull/601 | ||
|
||
|
||
## Usage | ||
|
||
log your messages using: | ||
``` | ||
@rango-dev/logging-core | ||
``` | ||
|
||
Listen to you logs (only on clients): | ||
```json | ||
"@rango-dev/logging-subscriber": "0.1.0", | ||
"@rango-dev/logging-console": "0.1.0", | ||
``` | ||
|
||
and | ||
|
||
```js | ||
import { init, Level } from '@rango-dev/logging-subscriber'; | ||
import { layer as consoleLayer } from '@rango-dev/logging-console'; | ||
|
||
init([consoleLayer()], { | ||
baseLevel: Level.Trace, | ||
}); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@rango-dev/logging-sentry", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"type": "module", | ||
"source": "./src/index.ts", | ||
"main": "./dist/index.js", | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"dependencies": { | ||
"@rango-dev/logging-types": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
"@sentry/browser": "^7.102.1" | ||
}, | ||
"scripts": { | ||
"build": "node ../../scripts/build/command.mjs --path logging/sentry", | ||
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json", | ||
"clean": "rimraf dist", | ||
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'", | ||
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
Oops, something went wrong.