-
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 pull request #2 from teal-finance/updatejslib
Improve typescript lib: compile with Rollup
- Loading branch information
Showing
11 changed files
with
266 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{constructor({zone:t=null,activatePrint:r=!0,activateEmojis:e=!0,hook:o=null}={zone:null,activatePrint:!0,activateEmojis:!0,hook:null}){this.zone=t,this.activatePrint=r,this.activateEmojis=e,this.hook=o}info(...t){return this.emo("ℹ️",t)}warning(...t){return this.emo("🔔",t)}error(...t){return this.emo("💢",t)}query(...t){return this.emo("🗄️",t)}queryError(...t){return this.emo("🗄️",t)}encrypt(...t){return this.emo("🎼",t)}encryptError(...t){return this.emo("🎼",t)}decrypt(...t){return this.emo("🗝️",t)}decryptError(...t){return this.emo("🗝️",t)}time(...t){return this.emo("⏱️",t)}timeError(...t){return this.emo("⏱️",t)}param(...t){return this.emo("📩",t)}paramError(...t){return this.emo("📩",t)}debug(...t){return this.emo("💊",t)}state(...t){return this.emo("📢",t)}save(...t){return this.emo("💾",t)}delete(...t){return this.emo("❌",t)}data(...t){return this.emo("💼",t)}line(...t){return this.emo("➖",t)}init(...t){return this.emo("🎬",t)}update(...t){return this.emo("🆙",t)}ok(...t){return this.emo("🆗",t)}build(...t){return this.emo("🔧",t)}aconstructor(...t){return this.emo("🛠️",t)}notFound(...t){return this.emo("🚫",t)}found(...t){return this.emo("👁️🗨️",t)}result(...t){return this.emo("📌",t)}input(...t){return this.emo("📥",t)}output(...t){return this.emo("📤",t)}function(...t){return this.emo("🔨",t)}key(...t){return this.emo("🔑",t)}security(...t){return this.emo("🔒",t)}accessToken(...t){return this.emo("🔑",t)}refreshToken(...t){return this.emo("🗝️",t)}transmit(...t){return this.emo("📡",t)}start(...t){return this.emo("🏁",t)}stop(...t){return this.emo("🛑",t)}in(...t){return this.emo("→",t)}out(...t){return this.emo("←",t)}arrowIn(...t){return this.emo("=>",t)}arrowOut(...t){return this.emo("<=",t)}smallArrowIn(...t){return this.emo("->",t)}smallArrowOut(...t){return this.emo("<-",t)}requestGet(...t){return this.emo("🔷",t)}requestPost(...t){return this.emo("🔶",t)}msg(...t){return this.emo("",t)}ready(...t){return 0===t.length&&(t[0]="ready"),this.emo("⏲️",t)}sep(){const t="➖➖➖➖➖➖➖➖➖➖➖";return this.activatePrint&&console.log(t),t}section(t){const r="➖➖➖➖➖ "+t+" ➖➖➖➖➖";return this.activatePrint&&console.log(r),r}sectionEnd(){return this.sep()}emo(t,r){const e=this._getEmoString(t,r);return this.activatePrint&&console.log(e),null!=this.hook&&this.hook(e),e}print(r){t.json(r)}static json(t){console.log(JSON.stringify(t,null," "))}_getEmoString(t,r){const e=new Array;return this.activateEmojis&&null!=t&&e.push(t),null!=this.zone&&e.push("["+this.zone+"]"),r.length>0&&r.forEach((t=>{"object"==typeof t?e.push(JSON.stringify(t)):e.push(t.toString())})),e.join(" ")}}exports.Emo=t; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,128 @@ | ||
// Code generated by https://github.com/teal-finance/emo/blob/main/codegen/ts/gen.go ; DO NOT EDIT. | ||
class Emo { | ||
/// Default constructor | ||
constructor({ zone = null, activatePrint = true, activateEmojis = true, hook = null } = { | ||
zone: null, | ||
activatePrint: true, | ||
activateEmojis: true, | ||
hook: null | ||
}) { | ||
this.zone = zone; | ||
this.activatePrint = activatePrint; | ||
this.activateEmojis = activateEmojis; | ||
this.hook = hook; | ||
} | ||
info(...obj) { return this.emo("ℹ️", obj); } | ||
warning(...obj) { return this.emo("🔔", obj); } | ||
error(...obj) { return this.emo("💢", obj); } | ||
query(...obj) { return this.emo("🗄️", obj); } | ||
queryError(...obj) { return this.emo("🗄️", obj); } | ||
encrypt(...obj) { return this.emo("🎼", obj); } | ||
encryptError(...obj) { return this.emo("🎼", obj); } | ||
decrypt(...obj) { return this.emo("🗝️", obj); } | ||
decryptError(...obj) { return this.emo("🗝️", obj); } | ||
time(...obj) { return this.emo("⏱️", obj); } | ||
timeError(...obj) { return this.emo("⏱️", obj); } | ||
param(...obj) { return this.emo("📩", obj); } | ||
paramError(...obj) { return this.emo("📩", obj); } | ||
debug(...obj) { return this.emo("💊", obj); } | ||
state(...obj) { return this.emo("📢", obj); } | ||
save(...obj) { return this.emo("💾", obj); } | ||
delete(...obj) { return this.emo("❌", obj); } | ||
data(...obj) { return this.emo("💼", obj); } | ||
line(...obj) { return this.emo("➖", obj); } | ||
init(...obj) { return this.emo("🎬", obj); } | ||
update(...obj) { return this.emo("🆙", obj); } | ||
ok(...obj) { return this.emo("🆗", obj); } | ||
build(...obj) { return this.emo("🔧", obj); } | ||
aconstructor(...obj) { return this.emo("🛠️", obj); } | ||
notFound(...obj) { return this.emo("🚫", obj); } | ||
found(...obj) { return this.emo("👁️🗨️", obj); } | ||
result(...obj) { return this.emo("📌", obj); } | ||
input(...obj) { return this.emo("📥", obj); } | ||
output(...obj) { return this.emo("📤", obj); } | ||
function(...obj) { return this.emo("🔨", obj); } | ||
key(...obj) { return this.emo("🔑", obj); } | ||
security(...obj) { return this.emo("🔒", obj); } | ||
accessToken(...obj) { return this.emo("🔑", obj); } | ||
refreshToken(...obj) { return this.emo("🗝️", obj); } | ||
transmit(...obj) { return this.emo("📡", obj); } | ||
start(...obj) { return this.emo("🏁", obj); } | ||
stop(...obj) { return this.emo("🛑", obj); } | ||
in(...obj) { return this.emo("→", obj); } | ||
out(...obj) { return this.emo("←", obj); } | ||
arrowIn(...obj) { return this.emo("=>", obj); } | ||
arrowOut(...obj) { return this.emo("<=", obj); } | ||
smallArrowIn(...obj) { return this.emo("->", obj); } | ||
smallArrowOut(...obj) { return this.emo("<-", obj); } | ||
requestGet(...obj) { return this.emo("🔷", obj); } | ||
requestPost(...obj) { return this.emo("🔶", obj); } | ||
/// A simple message with no emoji | ||
msg(...obj) { return this.emo("", obj); } | ||
/// A debug message for a ready state | ||
/// | ||
/// emoji: ⏲️ | ||
ready(...obj) { | ||
if (obj.length === 0) { | ||
obj[0] = "ready"; | ||
} | ||
return this.emo("⏲️", obj); | ||
} | ||
/// A separator line | ||
sep() { | ||
const msg = "➖➖➖➖➖➖➖➖➖➖➖"; | ||
if (this.activatePrint) { | ||
console.log(msg); | ||
} | ||
return msg; | ||
} | ||
/// A section start | ||
section(name) { | ||
const msg = "➖➖➖➖➖ " + name + " ➖➖➖➖➖"; | ||
if (this.activatePrint) { | ||
console.log(msg); | ||
} | ||
return msg; | ||
} | ||
/// A section end | ||
sectionEnd() { return this.sep(); } | ||
/// Print a debug message from an emoji | ||
emo(emoji, obj) { | ||
const msg = this._getEmoString(emoji, obj); | ||
if (this.activatePrint) { | ||
console.log(msg); | ||
} | ||
if (this.hook != null) { | ||
this.hook(msg); | ||
} | ||
return msg; | ||
} | ||
print(data) { | ||
Emo.json(data); | ||
} | ||
static json(data) { | ||
console.log(JSON.stringify(data, null, " ")); | ||
} | ||
_getEmoString(emoji, obj) { | ||
const l = new Array(); | ||
if (this.activateEmojis && emoji != null) { | ||
l.push(emoji); | ||
} | ||
if (this.zone != null) { | ||
l.push("[" + this.zone + "]"); | ||
} | ||
if (obj.length > 0) { | ||
obj.forEach((o) => { | ||
if (typeof o === 'object') { | ||
l.push(JSON.stringify(o)); | ||
} | ||
else { | ||
l.push(o.toString()); | ||
} | ||
}); | ||
} | ||
return l.join(" "); | ||
} | ||
} | ||
|
||
export { Emo }; |
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,63 @@ | ||
import { EmoParams } from './interfaces'; | ||
import { EmoHook } from './types'; | ||
export default class Emo { | ||
activatePrint: boolean; | ||
zone: string | null; | ||
hook: EmoHook | null; | ||
activateEmojis: boolean; | ||
constructor({ zone, activatePrint, activateEmojis, hook }?: EmoParams); | ||
info(...obj: any[]): string; | ||
warning(...obj: any[]): string; | ||
error(...obj: any[]): string; | ||
query(...obj: any[]): string; | ||
queryError(...obj: any[]): string; | ||
encrypt(...obj: any[]): string; | ||
encryptError(...obj: any[]): string; | ||
decrypt(...obj: any[]): string; | ||
decryptError(...obj: any[]): string; | ||
time(...obj: any[]): string; | ||
timeError(...obj: any[]): string; | ||
param(...obj: any[]): string; | ||
paramError(...obj: any[]): string; | ||
debug(...obj: any[]): string; | ||
state(...obj: any[]): string; | ||
save(...obj: any[]): string; | ||
delete(...obj: any[]): string; | ||
data(...obj: any[]): string; | ||
line(...obj: any[]): string; | ||
init(...obj: any[]): string; | ||
update(...obj: any[]): string; | ||
ok(...obj: any[]): string; | ||
build(...obj: any[]): string; | ||
aconstructor(...obj: any[]): string; | ||
notFound(...obj: any[]): string; | ||
found(...obj: any[]): string; | ||
result(...obj: any[]): string; | ||
input(...obj: any[]): string; | ||
output(...obj: any[]): string; | ||
function(...obj: any[]): string; | ||
key(...obj: any[]): string; | ||
security(...obj: any[]): string; | ||
accessToken(...obj: any[]): string; | ||
refreshToken(...obj: any[]): string; | ||
transmit(...obj: any[]): string; | ||
start(...obj: any[]): string; | ||
stop(...obj: any[]): string; | ||
in(...obj: any[]): string; | ||
out(...obj: any[]): string; | ||
arrowIn(...obj: any[]): string; | ||
arrowOut(...obj: any[]): string; | ||
smallArrowIn(...obj: any[]): string; | ||
smallArrowOut(...obj: any[]): string; | ||
requestGet(...obj: any[]): string; | ||
requestPost(...obj: any[]): string; | ||
msg(...obj: any[]): string; | ||
ready(...obj: any[]): string; | ||
sep(): string; | ||
section(name: string): string; | ||
sectionEnd(): string; | ||
emo(emoji: string, obj: Array<any>): string; | ||
print(data: Array<any> | Record<string, any>): void; | ||
static json(data: Array<any> | Record<string, any>): void; | ||
private _getEmoString; | ||
} |
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,8 @@ | ||
import { EmoHook } from './types'; | ||
interface EmoParams { | ||
zone?: string | null; | ||
activatePrint?: boolean; | ||
activateEmojis?: boolean; | ||
hook?: EmoHook | null; | ||
} | ||
export { EmoParams }; |
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,4 @@ | ||
import Emo from "./emo_gen"; | ||
import { EmoHook } from "./types"; | ||
import { EmoParams } from "./interfaces"; | ||
export { Emo, EmoHook, EmoParams }; |
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 @@ | ||
declare type EmoHook = (msg: string) => void; | ||
export { EmoHook }; |
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,35 @@ | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
|
||
//const isProduction = !process.env.ROLLUP_WATCH; | ||
|
||
export default { | ||
input: 'src/main.ts', | ||
output: [ | ||
{ | ||
file: 'dist/emo.min.cjs', | ||
format: 'cjs', | ||
plugins: [terser(),] | ||
}, | ||
{ | ||
file: 'dist/emo.mjs', | ||
format: 'esm' | ||
}, | ||
{ | ||
file: 'dist/emo.min.js', | ||
format: 'iife', | ||
name: '$emo', | ||
plugins: [terser()] | ||
}], | ||
plugins: [ | ||
typescript(), | ||
resolve({ | ||
jsnext: true, | ||
main: true, | ||
browser: true, | ||
}), | ||
commonjs(), | ||
], | ||
}; |
File renamed without changes.
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