@kform/core
Version:
JavaScript bindings for KForm.
444 lines (442 loc) • 13.8 kB
JavaScript
import {
Unit_instance1fbcbse1fwigr as Unit_instance,
VOID3gxj6tk5isa35 as VOID,
initMetadataForInterface1egvbzx539z91 as initMetadataForInterface,
initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
initMetadataForObject1cxne3s9w65el as initMetadataForObject,
THROW_IAE23kobfj9wdoxr as THROW_IAE,
Enum3alwj03lh1n41 as Enum,
toString30pk9tzaqopn as toString,
Exceptiondt2hlxn7j7vw as Exception,
equals2au1ep9vhcato as equals,
StringBuildermazzzhj6kkai as StringBuilder,
createThis2j2avj17cvnv2 as createThis,
hashCodeq5arwsb9dgti as hashCode,
getStringHashCode26igk1bx568vk as getStringHashCode,
THROW_CCE2g6jy02ryeudk as THROW_CCE,
protoOf180f3jzyo7rfj as protoOf,
noWhenBranchMatchedException2a6r7ubxgky5j as noWhenBranchMatchedException,
stackTraceToString2670q6lbhdojj as stackTraceToString,
split2bvyvnrlcifjv as split,
substringBeforekje8w2lxhyb6 as substringBefore,
substringAfterLastuw9v7gfiiihe as substringAfterLast,
contains3ue2qo8xhmpf1 as contains,
} from './kotlin-kotlin-stdlib.mjs';
//region block: imports
var imul = Math.imul;
//endregion
//region block: pre-declaration
class KLogger {}
function trace(message) {
var tmp = Level_TRACE_getInstance();
return this.l11(tmp, VOID, KLogger$trace$lambda(message));
}
function debug(message) {
var tmp = Level_DEBUG_getInstance();
return this.l11(tmp, VOID, KLogger$debug$lambda(message));
}
function error(throwable, message) {
var tmp = Level_ERROR_getInstance();
return this.l11(tmp, VOID, KLogger$error$lambda(message, throwable));
}
function at$default(level, marker, block, $super) {
marker = marker === VOID ? null : marker;
var tmp;
if ($super === VOID) {
this.o11(level, marker, block);
tmp = Unit_instance;
} else {
tmp = $super.o11.call(this, level, marker, block);
}
return tmp;
}
function isDebugEnabled(marker) {
return this.q11(Level_DEBUG_getInstance(), marker);
}
function isDebugEnabled$default(marker, $super) {
marker = marker === VOID ? null : marker;
return $super === VOID ? this.p11(marker) : isDebugEnabled(marker);
}
class KLoggingEventBuilder {
constructor() {
this.f11_1 = null;
this.g11_1 = null;
this.h11_1 = null;
this.i11_1 = null;
this.j11_1 = null;
}
}
class KotlinLogging {
s11(func) {
return this.u11(KLoggerNameResolver_instance.t11(func));
}
u11(name) {
return KLoggerFactory_instance.u11(name);
}
}
class Level extends Enum {
constructor(name, ordinal, levelInt, levelStr) {
super(name, ordinal);
this.x11_1 = levelInt;
this.y11_1 = levelStr;
}
toString() {
return this.y11_1;
}
}
class DefaultErrorMessageProducer {
z11(e) {
return 'Log message invocation failed: ' + e.toString();
}
}
class FormattingAppender {
b12(loggingEvent) {
// Inline function 'kotlin.let' call
var it = KotlinLoggingConfiguration_getInstance().d12_1.f12(loggingEvent);
this.a12(loggingEvent, it);
}
}
class DefaultMessageFormatter {
constructor(includePrefix) {
includePrefix = includePrefix === VOID ? true : includePrefix;
this.g12_1 = includePrefix;
}
f12(loggingEvent) {
// Inline function 'kotlin.with' call
// Inline function 'kotlin.text.buildString' call
// Inline function 'kotlin.apply' call
var this_0 = StringBuilder.u();
this_0.xc(prefix(this, loggingEvent.h12_1, loggingEvent.j12_1));
var tmp0_safe_receiver = loggingEvent.i12_1;
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.n12();
if (tmp1_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
this_0.xc(tmp1_safe_receiver);
this_0.xc(' ');
}
this_0.xc(loggingEvent.k12_1);
this_0.xc(throwableToString(this, loggingEvent.l12_1));
return this_0.toString();
}
}
class KLoggingEvent {
static o12(level, marker, loggerName, message, cause, payload) {
message = message === VOID ? null : message;
cause = cause === VOID ? null : cause;
payload = payload === VOID ? null : payload;
var $this = createThis(this);
$this.h12_1 = level;
$this.i12_1 = marker;
$this.j12_1 = loggerName;
$this.k12_1 = message;
$this.l12_1 = cause;
$this.m12_1 = payload;
return $this;
}
static p12(level, marker, loggerName, eventBuilder) {
return this.o12(level, marker, loggerName, eventBuilder.f11_1, eventBuilder.g11_1, eventBuilder.h11_1);
}
toString() {
return 'KLoggingEvent(level=' + this.h12_1.toString() + ', marker=' + toString(this.i12_1) + ', loggerName=' + this.j12_1 + ', message=' + this.k12_1 + ', cause=' + toString(this.l12_1) + ', payload=' + toString(this.m12_1) + ')';
}
hashCode() {
var result = this.h12_1.hashCode();
result = imul(result, 31) + (this.i12_1 == null ? 0 : hashCode(this.i12_1)) | 0;
result = imul(result, 31) + getStringHashCode(this.j12_1) | 0;
result = imul(result, 31) + (this.k12_1 == null ? 0 : getStringHashCode(this.k12_1)) | 0;
result = imul(result, 31) + (this.l12_1 == null ? 0 : hashCode(this.l12_1)) | 0;
result = imul(result, 31) + (this.m12_1 == null ? 0 : hashCode(this.m12_1)) | 0;
return result;
}
equals(other) {
if (this === other)
return true;
if (!(other instanceof KLoggingEvent))
return false;
var tmp0_other_with_cast = other instanceof KLoggingEvent ? other : THROW_CCE();
if (!this.h12_1.equals(tmp0_other_with_cast.h12_1))
return false;
if (!equals(this.i12_1, tmp0_other_with_cast.i12_1))
return false;
if (!(this.j12_1 === tmp0_other_with_cast.j12_1))
return false;
if (!(this.k12_1 == tmp0_other_with_cast.k12_1))
return false;
if (!equals(this.l12_1, tmp0_other_with_cast.l12_1))
return false;
if (!equals(this.m12_1, tmp0_other_with_cast.m12_1))
return false;
return true;
}
}
class KLoggerDirect {
constructor(name) {
this.q12_1 = name;
}
o11(level, marker, block) {
if (this.q11(level, marker)) {
// Inline function 'kotlin.apply' call
var this_0 = new KLoggingEventBuilder();
block(this_0);
// Inline function 'kotlin.run' call
if (level.g3_1 !== 5) {
KotlinLoggingConfiguration_getInstance().e12_1.b12(KLoggingEvent.p12(level, marker, this.q12_1, this_0));
}
}
}
q11(level, marker) {
return isLoggingEnabled(level);
}
}
class KLoggerFactory {
u11(name) {
return new KLoggerDirect(name);
}
}
class ConsoleOutputAppender extends FormattingAppender {
a12(loggingEvent, formattedMessage) {
switch (loggingEvent.h12_1.g3_1) {
case 0:
console.log(formattedMessage);
break;
case 1:
console.log(formattedMessage);
break;
case 2:
console.info(formattedMessage);
break;
case 3:
console.warn(formattedMessage);
break;
case 4:
console.error(formattedMessage);
break;
case 5:
break;
default:
noWhenBranchMatchedException();
break;
}
}
}
class KotlinLoggingConfiguration {
constructor() {
KotlinLoggingConfiguration_instance = this;
this.c12_1 = Level_INFO_getInstance();
this.d12_1 = new DefaultMessageFormatter(true);
this.e12_1 = new ConsoleOutputAppender();
}
}
class KLoggerNameResolver {
t11(func) {
var found = false;
var exception = Exception.pf();
var _iterator__ex2g4s = split(stackTraceToString(exception), ['\n']).z();
while (_iterator__ex2g4s.a1()) {
var line = _iterator__ex2g4s.b1();
if (found) {
return substringAfterLast(substringAfterLast(substringBefore(line, '.kt'), '.'), '/');
}
if (contains(line, 'at KotlinLogging')) {
found = true;
}
}
return '';
}
}
//endregion
function KLogger$trace$lambda($message) {
return function ($this$at) {
$this$at.f11_1 = toStringSafe($message);
return Unit_instance;
};
}
function KLogger$debug$lambda($message) {
return function ($this$at) {
$this$at.f11_1 = toStringSafe($message);
return Unit_instance;
};
}
function KLogger$error$lambda($message, $throwable) {
return function ($this$at) {
$this$at.f11_1 = toStringSafe($message);
$this$at.g11_1 = $throwable;
return Unit_instance;
};
}
var KotlinLogging_instance;
function KotlinLogging_getInstance() {
return KotlinLogging_instance;
}
var Level_TRACE_instance;
var Level_DEBUG_instance;
var Level_INFO_instance;
var Level_WARN_instance;
var Level_ERROR_instance;
var Level_OFF_instance;
function valueOf(value) {
switch (value) {
case 'TRACE':
return Level_TRACE_getInstance();
case 'DEBUG':
return Level_DEBUG_getInstance();
case 'INFO':
return Level_INFO_getInstance();
case 'WARN':
return Level_WARN_getInstance();
case 'ERROR':
return Level_ERROR_getInstance();
case 'OFF':
return Level_OFF_getInstance();
default:
Level_initEntries();
THROW_IAE('No enum constant value.');
break;
}
}
var Level_entriesInitialized;
function Level_initEntries() {
if (Level_entriesInitialized)
return Unit_instance;
Level_entriesInitialized = true;
Level_TRACE_instance = new Level('TRACE', 0, 0, 'TRACE');
Level_DEBUG_instance = new Level('DEBUG', 1, 10, 'DEBUG');
Level_INFO_instance = new Level('INFO', 2, 20, 'INFO');
Level_WARN_instance = new Level('WARN', 3, 30, 'WARN');
Level_ERROR_instance = new Level('ERROR', 4, 40, 'ERROR');
Level_OFF_instance = new Level('OFF', 5, 50, 'OFF');
}
function Level_TRACE_getInstance() {
Level_initEntries();
return Level_TRACE_instance;
}
function Level_DEBUG_getInstance() {
Level_initEntries();
return Level_DEBUG_instance;
}
function Level_INFO_getInstance() {
Level_initEntries();
return Level_INFO_instance;
}
function Level_WARN_getInstance() {
Level_initEntries();
return Level_WARN_instance;
}
function Level_ERROR_getInstance() {
Level_initEntries();
return Level_ERROR_instance;
}
function Level_OFF_getInstance() {
Level_initEntries();
return Level_OFF_instance;
}
function toStringSafe(_this__u8e3s4) {
var tmp;
try {
tmp = toString(_this__u8e3s4());
} catch ($p) {
var tmp_0;
if ($p instanceof Exception) {
var e = $p;
tmp_0 = DefaultErrorMessageProducer_instance.z11(e);
} else {
throw $p;
}
tmp = tmp_0;
}
return tmp;
}
var DefaultErrorMessageProducer_instance;
function DefaultErrorMessageProducer_getInstance() {
return DefaultErrorMessageProducer_instance;
}
function prefix($this, level, loggerName) {
var tmp;
if ($this.g12_1) {
tmp = level.f3_1 + ': [' + loggerName + '] ';
} else {
tmp = '';
}
return tmp;
}
function throwableToString($this, _this__u8e3s4) {
return createThrowableMsg($this, '', _this__u8e3s4);
}
function createThrowableMsg($this, msg, throwable) {
var $this_0 = $this;
var msg_0 = msg;
var throwable_0 = throwable;
$l$1: do {
$l$0: do {
var tmp;
if (throwable_0 == null || equals(throwable_0.cause, throwable_0)) {
tmp = msg_0;
} else {
var tmp0 = $this_0;
var tmp1 = msg_0 + ", Caused by: '" + throwable_0.message + "'";
var tmp2 = throwable_0.cause;
$this_0 = tmp0;
msg_0 = tmp1;
throwable_0 = tmp2;
continue $l$0;
}
return tmp;
}
while (false);
}
while (true);
}
function isLoggingEnabled(_this__u8e3s4) {
return _this__u8e3s4.g3_1 >= KotlinLoggingConfiguration_getInstance().c12_1.g3_1;
}
var KLoggerFactory_instance;
function KLoggerFactory_getInstance() {
return KLoggerFactory_instance;
}
var KotlinLoggingConfiguration_instance;
function KotlinLoggingConfiguration_getInstance() {
if (KotlinLoggingConfiguration_instance === VOID)
new KotlinLoggingConfiguration();
return KotlinLoggingConfiguration_instance;
}
var KLoggerNameResolver_instance;
function KLoggerNameResolver_getInstance() {
return KLoggerNameResolver_instance;
}
//region block: post-declaration
initMetadataForInterface(KLogger, 'KLogger');
initMetadataForClass(KLoggingEventBuilder, 'KLoggingEventBuilder', KLoggingEventBuilder);
initMetadataForObject(KotlinLogging, 'KotlinLogging');
initMetadataForClass(Level, 'Level');
initMetadataForObject(DefaultErrorMessageProducer, 'DefaultErrorMessageProducer');
initMetadataForClass(FormattingAppender, 'FormattingAppender');
initMetadataForClass(DefaultMessageFormatter, 'DefaultMessageFormatter', DefaultMessageFormatter);
initMetadataForClass(KLoggingEvent, 'KLoggingEvent');
protoOf(KLoggerDirect).l11 = at$default;
protoOf(KLoggerDirect).k11 = trace;
protoOf(KLoggerDirect).m11 = debug;
protoOf(KLoggerDirect).n11 = error;
protoOf(KLoggerDirect).p11 = isDebugEnabled;
protoOf(KLoggerDirect).r11 = isDebugEnabled$default;
initMetadataForClass(KLoggerDirect, 'KLoggerDirect', VOID, VOID, [KLogger]);
initMetadataForObject(KLoggerFactory, 'KLoggerFactory');
initMetadataForClass(ConsoleOutputAppender, 'ConsoleOutputAppender', ConsoleOutputAppender);
initMetadataForObject(KotlinLoggingConfiguration, 'KotlinLoggingConfiguration');
initMetadataForObject(KLoggerNameResolver, 'KLoggerNameResolver');
//endregion
//region block: init
KotlinLogging_instance = new KotlinLogging();
DefaultErrorMessageProducer_instance = new DefaultErrorMessageProducer();
KLoggerFactory_instance = new KLoggerFactory();
KLoggerNameResolver_instance = new KLoggerNameResolver();
//endregion
//region block: exports
export {
KotlinLoggingConfiguration_getInstance as KotlinLoggingConfiguration_getInstance1a1n660un4hfw,
KotlinLogging_instance as KotlinLogging_instance177vcamif7bv,
valueOf as valueOf1uc4ed064hut4,
};
//endregion
//# sourceMappingURL=kotlin-logging.mjs.map