@cpaassdk/cpaas-sdk
Version:
434 lines (426 loc) • 17 kB
JavaScript
(function (root, factory) {
if (typeof define === 'function' && define.amd)
define(['exports', './ktor-ktor-http-js-ir.js', './kotlin-kotlin-stdlib-js-ir.js', './ktor-ktor-utils-js-ir.js', './ktor-ktor-client-core-js-ir.js', './ktor-ktor-io-js-ir.js'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('./ktor-ktor-http-js-ir.js'), require('./kotlin-kotlin-stdlib-js-ir.js'), require('./ktor-ktor-utils-js-ir.js'), require('./ktor-ktor-client-core-js-ir.js'), require('./ktor-ktor-io-js-ir.js'));
else {
if (typeof this['ktor-ktor-http-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-client-json-js-ir'. Its dependency 'ktor-ktor-http-js-ir' was not found. Please, check whether 'ktor-ktor-http-js-ir' is loaded prior to 'ktor-ktor-client-json-js-ir'.");
}
if (typeof this['kotlin-kotlin-stdlib-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-client-json-js-ir'. Its dependency 'kotlin-kotlin-stdlib-js-ir' was not found. Please, check whether 'kotlin-kotlin-stdlib-js-ir' is loaded prior to 'ktor-ktor-client-json-js-ir'.");
}
if (typeof this['ktor-ktor-utils-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-client-json-js-ir'. Its dependency 'ktor-ktor-utils-js-ir' was not found. Please, check whether 'ktor-ktor-utils-js-ir' is loaded prior to 'ktor-ktor-client-json-js-ir'.");
}
if (typeof this['ktor-ktor-client-core-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-client-json-js-ir'. Its dependency 'ktor-ktor-client-core-js-ir' was not found. Please, check whether 'ktor-ktor-client-core-js-ir' is loaded prior to 'ktor-ktor-client-json-js-ir'.");
}
if (typeof this['ktor-ktor-io-js-ir'] === 'undefined') {
throw new Error("Error loading module 'ktor-ktor-client-json-js-ir'. Its dependency 'ktor-ktor-io-js-ir' was not found. Please, check whether 'ktor-ktor-io-js-ir' is loaded prior to 'ktor-ktor-client-json-js-ir'.");
}
root['ktor-ktor-client-json-js-ir'] = factory(typeof this['ktor-ktor-client-json-js-ir'] === 'undefined' ? {} : this['ktor-ktor-client-json-js-ir'], this['ktor-ktor-http-js-ir'], this['kotlin-kotlin-stdlib-js-ir'], this['ktor-ktor-utils-js-ir'], this['ktor-ktor-client-core-js-ir'], this['ktor-ktor-io-js-ir']);
}
}(this, function (_, kotlin_io_ktor_ktor_http, kotlin_kotlin, kotlin_io_ktor_ktor_utils, kotlin_io_ktor_ktor_client_core, kotlin_io_ktor_ktor_io) {
'use strict';
//region block: imports
var Application_getInstance = kotlin_io_ktor_ktor_http.$_$.e;
var endsWith$default = kotlin_kotlin.$_$.m;
var startsWith$default = kotlin_kotlin.$_$.w;
var ContentTypeMatcher = kotlin_io_ktor_ktor_http.$_$.t;
var classMeta = kotlin_kotlin.$_$.x8;
var CoroutineImpl = kotlin_kotlin.$_$.h8;
var Unit_getInstance = kotlin_kotlin.$_$.h4;
var THROW_CCE = kotlin_kotlin.$_$.qc;
var PipelineContext = kotlin_io_ktor_ktor_utils.$_$.g;
var isInterface = kotlin_kotlin.$_$.p9;
var isObject = kotlin_kotlin.$_$.s9;
var accept = kotlin_io_ktor_ktor_client_core.$_$.h;
var contentType = kotlin_io_ktor_ktor_http.$_$.e1;
var HttpHeaders_getInstance = kotlin_io_ktor_ktor_http.$_$.i;
var EmptyContent_getInstance = kotlin_io_ktor_ktor_client_core.$_$.d;
var EmptyContent = kotlin_io_ktor_ktor_client_core.$_$.m;
var equals = kotlin_kotlin.$_$.z8;
var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.s7;
var HttpResponseContainer = kotlin_io_ktor_ktor_client_core.$_$.i;
var ByteReadChannel = kotlin_io_ktor_ktor_io.$_$.g1;
var contentType_0 = kotlin_io_ktor_ktor_http.$_$.f1;
var readRemaining = kotlin_io_ktor_ktor_io.$_$.c;
var mutableListOf = kotlin_kotlin.$_$.t6;
var AttributeKey = kotlin_io_ktor_ktor_utils.$_$.m;
var toList = kotlin_kotlin.$_$.i7;
var Phases_getInstance = kotlin_io_ktor_ktor_client_core.$_$.b;
var Phases_getInstance_0 = kotlin_io_ktor_ktor_client_core.$_$.c;
var HttpClientFeature = kotlin_io_ktor_ktor_client_core.$_$.f;
var objectMeta = kotlin_kotlin.$_$.da;
var Collection = kotlin_kotlin.$_$.j4;
var SuspendFunction2 = kotlin_kotlin.$_$.k8;
var TypeInfo = kotlin_io_ktor_ktor_utils.$_$.j;
var TypeInfo_0 = kotlin_io_ktor_ktor_client_core.$_$.e;
var interfaceMeta = kotlin_kotlin.$_$.g9;
var first = kotlin_kotlin.$_$.e6;
var ArrayList_init_$Create$ = kotlin_kotlin.$_$.a1;
//endregion
//region block: pre-declaration
JsonFeature$Feature$install$slambda.prototype = Object.create(CoroutineImpl.prototype);
JsonFeature$Feature$install$slambda.prototype.constructor = JsonFeature$Feature$install$slambda;
JsonFeature$Feature$install$slambda_1.prototype = Object.create(CoroutineImpl.prototype);
JsonFeature$Feature$install$slambda_1.prototype.constructor = JsonFeature$Feature$install$slambda_1;
function read(type, body) {
return this.h3g(isInterface(type, TypeInfo) ? type : THROW_CCE(), body);
}
function read_0(type, body) {
return this.y3f(new TypeInfo_0(type.x22(), type.y22(), type.z22()), body);
}
//endregion
function JsonContentTypeMatcher() {
}
JsonContentTypeMatcher.prototype.q23 = function (contentType) {
if (Application_getInstance().f24_1.l25(contentType)) {
return true;
}
var value = contentType.k25().toString();
var tmp;
if (startsWith$default(value, 'application/', false, 2, null)) {
tmp = endsWith$default(value, '+json', false, 2, null);
} else {
tmp = false;
}
return tmp;
};
JsonContentTypeMatcher.$metadata$ = classMeta('JsonContentTypeMatcher', [ContentTypeMatcher]);
function JsonFeature$Feature$install$slambda($feature, resultContinuation) {
this.v3e_1 = $feature;
CoroutineImpl.call(this, resultContinuation);
}
JsonFeature$Feature$install$slambda.prototype.j2h = function ($this$intercept, payload, $cont) {
var tmp = this.k2h($this$intercept, payload, $cont);
tmp.ki_1 = Unit_getInstance();
tmp.li_1 = null;
return tmp.si();
};
JsonFeature$Feature$install$slambda.prototype.m7 = function (p1, p2, $cont) {
var tmp = (!(p1 == null) ? isInterface(p1, PipelineContext) : false) ? p1 : THROW_CCE();
return this.j2h(tmp, isObject(p2) ? p2 : THROW_CCE(), $cont);
};
JsonFeature$Feature$install$slambda.prototype.si = function () {
var suspendResult = this.ki_1;
$sm: do
try {
var tmp = this.ii_1;
switch (tmp) {
case 0:
this.ji_1 = 2;
var tmp_0 = this;
tmp_0.y3e_1 = this.v3e_1.c3f_1;
var tmp0_iterator = this.y3e_1.g();
while (tmp0_iterator.h()) {
var element = tmp0_iterator.i();
accept(this.w3e_1.u4(), element);
}
var tmp_1 = this;
var tmp0_elvis_lhs = contentType(this.w3e_1.u4());
var tmp_2;
if (tmp0_elvis_lhs == null) {
return Unit_getInstance();
} else {
tmp_2 = tmp0_elvis_lhs;
}
tmp_1.z3e_1 = tmp_2;
if (!this.v3e_1.e3f(this.z3e_1))
return Unit_getInstance();
this.w3e_1.u4().e2i_1.d1w(HttpHeaders_getInstance().j26_1);
var tmp_3 = this;
var tmp1_subject = this.x3e_1;
var tmp_4;
if (equals(tmp1_subject, Unit_getInstance())) {
tmp_4 = EmptyContent_getInstance();
} else {
if (tmp1_subject instanceof EmptyContent) {
tmp_4 = EmptyContent_getInstance();
} else {
tmp_4 = this.v3e_1.b3f_1.f3f(this.x3e_1, this.z3e_1);
}
}
tmp_3.a3f_1 = tmp_4;
this.ii_1 = 1;
suspendResult = this.w3e_1.v20(this.a3f_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
;
return Unit_getInstance();
case 2:
throw this.li_1;
}
} catch ($p) {
if (this.ji_1 === 2) {
throw $p;
} else {
this.ii_1 = this.ji_1;
this.li_1 = $p;
}
}
while (true);
};
JsonFeature$Feature$install$slambda.prototype.k2h = function ($this$intercept, payload, completion) {
var i = new JsonFeature$Feature$install$slambda(this.v3e_1, completion);
i.w3e_1 = $this$intercept;
i.x3e_1 = payload;
return i;
};
JsonFeature$Feature$install$slambda.$metadata$ = classMeta('JsonFeature$Feature$install$slambda', undefined, undefined, undefined, [2], CoroutineImpl.prototype);
function JsonFeature$Feature$install$slambda_0($feature, resultContinuation) {
var i = new JsonFeature$Feature$install$slambda($feature, resultContinuation);
var l = function ($this$intercept, payload, $cont) {
return i.j2h($this$intercept, payload, $cont);
};
l.$arity = 2;
return l;
}
function JsonFeature$Feature$install$slambda_1($feature, resultContinuation) {
this.o3f_1 = $feature;
CoroutineImpl.call(this, resultContinuation);
}
JsonFeature$Feature$install$slambda_1.prototype.f2u = function ($this$intercept, _name_for_destructuring_parameter_0__wldtmu, $cont) {
var tmp = this.g2u($this$intercept, _name_for_destructuring_parameter_0__wldtmu, $cont);
tmp.ki_1 = Unit_getInstance();
tmp.li_1 = null;
return tmp.si();
};
JsonFeature$Feature$install$slambda_1.prototype.m7 = function (p1, p2, $cont) {
var tmp = (!(p1 == null) ? isInterface(p1, PipelineContext) : false) ? p1 : THROW_CCE();
return this.f2u(tmp, p2 instanceof HttpResponseContainer ? p2 : THROW_CCE(), $cont);
};
JsonFeature$Feature$install$slambda_1.prototype.si = function () {
var suspendResult = this.ki_1;
$sm: do
try {
var tmp = this.ii_1;
switch (tmp) {
case 0:
this.ji_1 = 3;
this.r3f_1 = this.q3f_1.k4();
this.s3f_1 = this.q3f_1.l4();
var tmp_0 = this.s3f_1;
if (!isInterface(tmp_0, ByteReadChannel))
return Unit_getInstance();
var tmp_1 = this;
var tmp0_elvis_lhs = contentType_0(this.p3f_1.u4().q2h());
var tmp_2;
if (tmp0_elvis_lhs == null) {
return Unit_getInstance();
} else {
tmp_2 = tmp0_elvis_lhs;
}
tmp_1.t3f_1 = tmp_2;
if (!this.o3f_1.e3f(this.t3f_1))
return Unit_getInstance();
this.u3f_1 = this.o3f_1.b3f_1;
this.ii_1 = 1;
suspendResult = readRemaining(this.s3f_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
this.v3f_1 = suspendResult;
this.w3f_1 = this.u3f_1.y3f(this.r3f_1, this.v3f_1);
this.x3f_1 = new HttpResponseContainer(this.r3f_1, this.w3f_1);
this.ii_1 = 2;
suspendResult = this.p3f_1.v20(this.x3f_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 2:
;
return Unit_getInstance();
case 3:
throw this.li_1;
}
} catch ($p) {
if (this.ji_1 === 3) {
throw $p;
} else {
this.ii_1 = this.ji_1;
this.li_1 = $p;
}
}
while (true);
};
JsonFeature$Feature$install$slambda_1.prototype.g2u = function ($this$intercept, _name_for_destructuring_parameter_0__wldtmu, completion) {
var i = new JsonFeature$Feature$install$slambda_1(this.o3f_1, completion);
i.p3f_1 = $this$intercept;
i.q3f_1 = _name_for_destructuring_parameter_0__wldtmu;
return i;
};
JsonFeature$Feature$install$slambda_1.$metadata$ = classMeta('JsonFeature$Feature$install$slambda', undefined, undefined, undefined, [2], CoroutineImpl.prototype);
function JsonFeature$Feature$install$slambda_2($feature, resultContinuation) {
var i = new JsonFeature$Feature$install$slambda_1($feature, resultContinuation);
var l = function ($this$intercept, _name_for_destructuring_parameter_0__wldtmu, $cont) {
return i.f2u($this$intercept, _name_for_destructuring_parameter_0__wldtmu, $cont);
};
l.$arity = 2;
return l;
}
function Config() {
this.z3f_1 = null;
this.a3g_1 = mutableListOf([Application_getInstance().f24_1]);
this.b3g_1 = mutableListOf([new JsonContentTypeMatcher()]);
}
Config.prototype.c3g = function () {
return this.a3g_1;
};
Config.prototype.d3g = function () {
return this.b3g_1;
};
Config.$metadata$ = classMeta('Config');
function Feature() {
Feature_instance = this;
this.e3g_1 = new AttributeKey('Json');
}
Feature.prototype.x = function () {
return this.e3g_1;
};
Feature.prototype.f3g = function (block) {
var tmp$ret$0;
{
var tmp0_apply = new Config();
{
}
block(tmp0_apply);
tmp$ret$0 = tmp0_apply;
}
var config = tmp$ret$0;
var tmp0_elvis_lhs = config.z3f_1;
var serializer = tmp0_elvis_lhs == null ? defaultSerializer() : tmp0_elvis_lhs;
var allowedContentTypes = toList(config.c3g());
var receiveContentTypeMatchers = config.d3g();
return new JsonFeature(serializer, allowedContentTypes, receiveContentTypeMatchers);
};
Feature.prototype.f2j = function (block) {
return this.f3g(block);
};
Feature.prototype.g3g = function (feature, scope) {
var tmp = Phases_getInstance().k2p_1;
scope.p2g_1.x21(tmp, JsonFeature$Feature$install$slambda_0(feature, null));
var tmp_0 = Phases_getInstance_0().x2r_1;
scope.q2g_1.x21(tmp_0, JsonFeature$Feature$install$slambda_2(feature, null));
};
Feature.prototype.g2j = function (feature, scope) {
return this.g3g(feature instanceof JsonFeature ? feature : THROW_CCE(), scope);
};
Feature.$metadata$ = objectMeta('Feature', [HttpClientFeature]);
var Feature_instance;
function Feature_getInstance() {
if (Feature_instance == null)
new Feature();
return Feature_instance;
}
function JsonFeature(serializer, acceptContentTypes, receiveContentTypeMatchers) {
Feature_getInstance();
this.b3f_1 = serializer;
this.c3f_1 = acceptContentTypes;
this.d3f_1 = receiveContentTypeMatchers;
}
JsonFeature.prototype.e3f = function (contentType) {
var tmp$ret$0;
$l$block_0: {
var tmp0_any = this.c3f_1;
var tmp;
if (isInterface(tmp0_any, Collection)) {
tmp = tmp0_any.m();
} else {
tmp = false;
}
if (tmp) {
tmp$ret$0 = false;
break $l$block_0;
}
var tmp0_iterator = tmp0_any.g();
while (tmp0_iterator.h()) {
var element = tmp0_iterator.i();
var tmp$ret$1;
{
tmp$ret$1 = contentType.l25(element);
}
if (tmp$ret$1) {
tmp$ret$0 = true;
break $l$block_0;
}
}
tmp$ret$0 = false;
}
var accepted = tmp$ret$0;
var matchers = this.d3f_1;
var tmp_0;
if (accepted) {
tmp_0 = true;
} else {
var tmp$ret$2;
$l$block_2: {
var tmp_1;
if (isInterface(matchers, Collection)) {
tmp_1 = matchers.m();
} else {
tmp_1 = false;
}
if (tmp_1) {
tmp$ret$2 = false;
break $l$block_2;
}
var tmp0_iterator_0 = matchers.g();
while (tmp0_iterator_0.h()) {
var element_0 = tmp0_iterator_0.i();
var tmp$ret$3;
{
tmp$ret$3 = element_0.q23(contentType);
}
if (tmp$ret$3) {
tmp$ret$2 = true;
break $l$block_2;
}
}
tmp$ret$2 = false;
}
tmp_0 = tmp$ret$2;
}
return tmp_0;
};
JsonFeature.$metadata$ = classMeta('JsonFeature');
function JsonSerializer() {
}
JsonSerializer.$metadata$ = interfaceMeta('JsonSerializer');
function get_serializersStore() {
init_properties_DefaultJs_kt_5pqbey();
return serializersStore;
}
var serializersStore;
function defaultSerializer() {
init_properties_DefaultJs_kt_5pqbey();
return first(get_serializersStore());
}
var properties_initialized_DefaultJs_kt_mit67a;
function init_properties_DefaultJs_kt_5pqbey() {
if (properties_initialized_DefaultJs_kt_mit67a) {
} else {
properties_initialized_DefaultJs_kt_mit67a = true;
var tmp$ret$0;
{
tmp$ret$0 = ArrayList_init_$Create$();
}
serializersStore = tmp$ret$0;
}
}
//region block: exports
_.$_$ = _.$_$ || {};
_.$_$.a = Feature_getInstance;
_.$_$.b = read;
_.$_$.c = JsonSerializer;
//endregion
return _;
}));
//# sourceMappingURL=ktor-ktor-client-json-js-ir.js.map