UNPKG

@earth-app/shovel

Version:

Kotlin Multiplatform Web Scraping Framework

448 lines (446 loc) 16.5 kB
(function (factory) { if (typeof define === 'function' && define.amd) define(['exports', './kotlin-kotlin-stdlib.js', './ktor-ktor-io.js', './kotlinx-io-kotlinx-io-core.js'], factory); else if (typeof exports === 'object') factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./ktor-ktor-io.js'), require('./kotlinx-io-kotlinx-io-core.js')); else { if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') { throw new Error("Error loading module 'ktor-ktor-websockets'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'ktor-ktor-websockets'."); } if (typeof globalThis['ktor-ktor-io'] === 'undefined') { throw new Error("Error loading module 'ktor-ktor-websockets'. Its dependency 'ktor-ktor-io' was not found. Please, check whether 'ktor-ktor-io' is loaded prior to 'ktor-ktor-websockets'."); } if (typeof globalThis['kotlinx-io-kotlinx-io-core'] === 'undefined') { throw new Error("Error loading module 'ktor-ktor-websockets'. Its dependency 'kotlinx-io-kotlinx-io-core' was not found. Please, check whether 'kotlinx-io-kotlinx-io-core' is loaded prior to 'ktor-ktor-websockets'."); } globalThis['ktor-ktor-websockets'] = factory(typeof globalThis['ktor-ktor-websockets'] === 'undefined' ? {} : globalThis['ktor-ktor-websockets'], globalThis['kotlin-kotlin-stdlib'], globalThis['ktor-ktor-io'], globalThis['kotlinx-io-kotlinx-io-core']); } }(function (_, kotlin_kotlin, kotlin_io_ktor_ktor_io, kotlin_org_jetbrains_kotlinx_kotlinx_io_core) { 'use strict'; //region block: imports var imul = Math.imul; var collectionSizeOrDefault = kotlin_kotlin.$_$.p3; var mapCapacity = kotlin_kotlin.$_$.p4; var coerceAtLeast = kotlin_kotlin.$_$.p8; var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.n; var Unit_instance = kotlin_kotlin.$_$.v2; var protoOf = kotlin_kotlin.$_$.j8; var initMetadataForCompanion = kotlin_kotlin.$_$.u7; var enumEntries = kotlin_kotlin.$_$.j6; var Enum = kotlin_kotlin.$_$.qb; var initMetadataForClass = kotlin_kotlin.$_$.t7; var VOID = kotlin_kotlin.$_$.b; var toString = kotlin_kotlin.$_$.m8; var getStringHashCode = kotlin_kotlin.$_$.r7; var initMetadataForObject = kotlin_kotlin.$_$.z7; var compareTo = kotlin_kotlin.$_$.k7; var ensureNotNull = kotlin_kotlin.$_$.ic; var objectCreate = kotlin_kotlin.$_$.i8; var toByteArray = kotlin_io_ktor_ktor_io.$_$.w; var Buffer = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.f; var writeText = kotlin_io_ktor_ktor_io.$_$.y; var readByteArray = kotlin_org_jetbrains_kotlinx_kotlinx_io_core.$_$.k; //endregion //region block: pre-declaration initMetadataForCompanion(Companion); initMetadataForClass(Codes, 'Codes', VOID, Enum); initMetadataForClass(CloseReason, 'CloseReason'); initMetadataForObject(NonDisposableHandle, 'NonDisposableHandle'); initMetadataForCompanion(Companion_0); initMetadataForClass(FrameType, 'FrameType', VOID, Enum); initMetadataForClass(Frame, 'Frame'); initMetadataForClass(Binary, 'Binary', VOID, Frame); initMetadataForClass(Text, 'Text', VOID, Frame); initMetadataForClass(Close, 'Close', Close_init_$Create$_0, Frame); initMetadataForCompanion(Companion_1); //endregion var Codes_NORMAL_instance; var Codes_GOING_AWAY_instance; var Codes_PROTOCOL_ERROR_instance; var Codes_CANNOT_ACCEPT_instance; var Codes_CLOSED_ABNORMALLY_instance; var Codes_NOT_CONSISTENT_instance; var Codes_VIOLATED_POLICY_instance; var Codes_TOO_BIG_instance; var Codes_NO_EXTENSION_instance; var Codes_INTERNAL_ERROR_instance; var Codes_SERVICE_RESTART_instance; var Codes_TRY_AGAIN_LATER_instance; function Companion() { Companion_instance = this; var tmp = this; // Inline function 'kotlin.collections.associateBy' call var this_0 = get_entries(); var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(this_0, 10)), 16); // Inline function 'kotlin.collections.associateByTo' call var destination = LinkedHashMap_init_$Create$(capacity); var _iterator__ex2g4s = this_0.q(); while (_iterator__ex2g4s.r()) { var element = _iterator__ex2g4s.s(); var tmp$ret$0 = element.q25_1; destination.j2(tmp$ret$0, element); } tmp.r25_1 = destination; this.s25_1 = Codes_INTERNAL_ERROR_getInstance(); } protoOf(Companion).t25 = function (code) { return this.r25_1.r2(code); }; var Companion_instance; function Companion_getInstance() { Codes_initEntries(); if (Companion_instance == null) new Companion(); return Companion_instance; } function values() { return [Codes_NORMAL_getInstance(), Codes_GOING_AWAY_getInstance(), Codes_PROTOCOL_ERROR_getInstance(), Codes_CANNOT_ACCEPT_getInstance(), Codes_CLOSED_ABNORMALLY_getInstance(), Codes_NOT_CONSISTENT_getInstance(), Codes_VIOLATED_POLICY_getInstance(), Codes_TOO_BIG_getInstance(), Codes_NO_EXTENSION_getInstance(), Codes_INTERNAL_ERROR_getInstance(), Codes_SERVICE_RESTART_getInstance(), Codes_TRY_AGAIN_LATER_getInstance()]; } function get_entries() { if ($ENTRIES == null) $ENTRIES = enumEntries(values()); return $ENTRIES; } var Codes_entriesInitialized; function Codes_initEntries() { if (Codes_entriesInitialized) return Unit_instance; Codes_entriesInitialized = true; Codes_NORMAL_instance = new Codes('NORMAL', 0, 1000); Codes_GOING_AWAY_instance = new Codes('GOING_AWAY', 1, 1001); Codes_PROTOCOL_ERROR_instance = new Codes('PROTOCOL_ERROR', 2, 1002); Codes_CANNOT_ACCEPT_instance = new Codes('CANNOT_ACCEPT', 3, 1003); Codes_CLOSED_ABNORMALLY_instance = new Codes('CLOSED_ABNORMALLY', 4, 1006); Codes_NOT_CONSISTENT_instance = new Codes('NOT_CONSISTENT', 5, 1007); Codes_VIOLATED_POLICY_instance = new Codes('VIOLATED_POLICY', 6, 1008); Codes_TOO_BIG_instance = new Codes('TOO_BIG', 7, 1009); Codes_NO_EXTENSION_instance = new Codes('NO_EXTENSION', 8, 1010); Codes_INTERNAL_ERROR_instance = new Codes('INTERNAL_ERROR', 9, 1011); Codes_SERVICE_RESTART_instance = new Codes('SERVICE_RESTART', 10, 1012); Codes_TRY_AGAIN_LATER_instance = new Codes('TRY_AGAIN_LATER', 11, 1013); Companion_getInstance(); } var $ENTRIES; function Codes(name, ordinal, code) { Enum.call(this, name, ordinal); this.q25_1 = code; } function Codes_NORMAL_getInstance() { Codes_initEntries(); return Codes_NORMAL_instance; } function Codes_GOING_AWAY_getInstance() { Codes_initEntries(); return Codes_GOING_AWAY_instance; } function Codes_PROTOCOL_ERROR_getInstance() { Codes_initEntries(); return Codes_PROTOCOL_ERROR_instance; } function Codes_CANNOT_ACCEPT_getInstance() { Codes_initEntries(); return Codes_CANNOT_ACCEPT_instance; } function Codes_CLOSED_ABNORMALLY_getInstance() { Codes_initEntries(); return Codes_CLOSED_ABNORMALLY_instance; } function Codes_NOT_CONSISTENT_getInstance() { Codes_initEntries(); return Codes_NOT_CONSISTENT_instance; } function Codes_VIOLATED_POLICY_getInstance() { Codes_initEntries(); return Codes_VIOLATED_POLICY_instance; } function Codes_TOO_BIG_getInstance() { Codes_initEntries(); return Codes_TOO_BIG_instance; } function Codes_NO_EXTENSION_getInstance() { Codes_initEntries(); return Codes_NO_EXTENSION_instance; } function Codes_INTERNAL_ERROR_getInstance() { Codes_initEntries(); return Codes_INTERNAL_ERROR_instance; } function Codes_SERVICE_RESTART_getInstance() { Codes_initEntries(); return Codes_SERVICE_RESTART_instance; } function Codes_TRY_AGAIN_LATER_getInstance() { Codes_initEntries(); return Codes_TRY_AGAIN_LATER_instance; } function CloseReason(code, message) { this.u25_1 = code; this.v25_1 = message; } protoOf(CloseReason).w25 = function () { return Companion_getInstance().t25(this.u25_1); }; protoOf(CloseReason).toString = function () { var tmp0_elvis_lhs = this.w25(); return 'CloseReason(reason=' + toString(tmp0_elvis_lhs == null ? this.u25_1 : tmp0_elvis_lhs) + ', message=' + this.v25_1 + ')'; }; protoOf(CloseReason).hashCode = function () { var result = this.u25_1; result = imul(result, 31) + getStringHashCode(this.v25_1) | 0; return result; }; protoOf(CloseReason).equals = function (other) { if (this === other) return true; if (!(other instanceof CloseReason)) return false; if (!(this.u25_1 === other.u25_1)) return false; if (!(this.v25_1 === other.v25_1)) return false; return true; }; function NonDisposableHandle() { } protoOf(NonDisposableHandle).ip = function () { return Unit_instance; }; protoOf(NonDisposableHandle).toString = function () { return 'NonDisposableHandle'; }; protoOf(NonDisposableHandle).hashCode = function () { return 207988788; }; protoOf(NonDisposableHandle).equals = function (other) { if (this === other) return true; if (!(other instanceof NonDisposableHandle)) return false; return true; }; var NonDisposableHandle_instance; function NonDisposableHandle_getInstance() { return NonDisposableHandle_instance; } var FrameType_TEXT_instance; var FrameType_BINARY_instance; var FrameType_CLOSE_instance; var FrameType_PING_instance; var FrameType_PONG_instance; function Companion_0() { Companion_instance_0 = this; var tmp = this; var tmp0 = get_entries_0(); var tmp$ret$0; $l$block_0: { // Inline function 'kotlin.collections.maxByOrNull' call var iterator = tmp0.q(); if (!iterator.r()) { tmp$ret$0 = null; break $l$block_0; } var maxElem = iterator.s(); if (!iterator.r()) { tmp$ret$0 = maxElem; break $l$block_0; } var maxValue = maxElem.a26_1; do { var e = iterator.s(); var v = e.a26_1; if (compareTo(maxValue, v) < 0) { maxElem = e; maxValue = v; } } while (iterator.r()); tmp$ret$0 = maxElem; } tmp.b26_1 = ensureNotNull(tmp$ret$0).a26_1; var tmp_0 = this; var tmp_1 = 0; var tmp_2 = this.b26_1 + 1 | 0; // Inline function 'kotlin.arrayOfNulls' call var tmp_3 = Array(tmp_2); while (tmp_1 < tmp_2) { var tmp_4 = tmp_1; var tmp0_0 = get_entries_0(); var tmp$ret$5; $l$block_2: { // Inline function 'kotlin.collections.singleOrNull' call var single = null; var found = false; var _iterator__ex2g4s = tmp0_0.q(); while (_iterator__ex2g4s.r()) { var element = _iterator__ex2g4s.s(); if (element.a26_1 === tmp_4) { if (found) { tmp$ret$5 = null; break $l$block_2; } single = element; found = true; } } if (!found) { tmp$ret$5 = null; break $l$block_2; } tmp$ret$5 = single; } tmp_3[tmp_4] = tmp$ret$5; tmp_1 = tmp_1 + 1 | 0; } tmp_0.c26_1 = tmp_3; } var Companion_instance_0; function Companion_getInstance_0() { FrameType_initEntries(); if (Companion_instance_0 == null) new Companion_0(); return Companion_instance_0; } function values_0() { return [FrameType_TEXT_getInstance(), FrameType_BINARY_getInstance(), FrameType_CLOSE_getInstance(), FrameType_PING_getInstance(), FrameType_PONG_getInstance()]; } function get_entries_0() { if ($ENTRIES_0 == null) $ENTRIES_0 = enumEntries(values_0()); return $ENTRIES_0; } var FrameType_entriesInitialized; function FrameType_initEntries() { if (FrameType_entriesInitialized) return Unit_instance; FrameType_entriesInitialized = true; FrameType_TEXT_instance = new FrameType('TEXT', 0, false, 1); FrameType_BINARY_instance = new FrameType('BINARY', 1, false, 2); FrameType_CLOSE_instance = new FrameType('CLOSE', 2, true, 8); FrameType_PING_instance = new FrameType('PING', 3, true, 9); FrameType_PONG_instance = new FrameType('PONG', 4, true, 10); Companion_getInstance_0(); } var $ENTRIES_0; function FrameType(name, ordinal, controlFrame, opcode) { Enum.call(this, name, ordinal); this.z25_1 = controlFrame; this.a26_1 = opcode; } function FrameType_TEXT_getInstance() { FrameType_initEntries(); return FrameType_TEXT_instance; } function FrameType_BINARY_getInstance() { FrameType_initEntries(); return FrameType_BINARY_instance; } function FrameType_CLOSE_getInstance() { FrameType_initEntries(); return FrameType_CLOSE_instance; } function FrameType_PING_getInstance() { FrameType_initEntries(); return FrameType_PING_instance; } function FrameType_PONG_getInstance() { FrameType_initEntries(); return FrameType_PONG_instance; } function Binary_init_$Init$(fin, data, $this) { Binary.call($this, fin, data, false, false, false); return $this; } function Binary_init_$Create$(fin, data) { return Binary_init_$Init$(fin, data, objectCreate(protoOf(Binary))); } function Text_init_$Init$(fin, data, $this) { Text.call($this, fin, data, false, false, false); return $this; } function Text_init_$Init$_0(text, $this) { Text_init_$Init$(true, toByteArray(text), $this); return $this; } function Text_init_$Create$(text) { return Text_init_$Init$_0(text, objectCreate(protoOf(Text))); } function Close_init_$Init$(reason, $this) { // Inline function 'io.ktor.utils.io.core.buildPacket' call var builder = new Buffer(); builder.g17(reason.u25_1); writeText(builder, reason.v25_1); Close_init_$Init$_0(builder, $this); return $this; } function Close_init_$Create$(reason) { return Close_init_$Init$(reason, objectCreate(protoOf(Close))); } function Close_init_$Init$_0(packet, $this) { Close.call($this, readByteArray(packet)); return $this; } function Close_init_$Init$_1($this) { Close.call($this, Companion_getInstance_1().d26_1); return $this; } function Close_init_$Create$_0() { return Close_init_$Init$_1(objectCreate(protoOf(Close))); } function Binary(fin, data, rsv1, rsv2, rsv3) { rsv1 = rsv1 === VOID ? false : rsv1; rsv2 = rsv2 === VOID ? false : rsv2; rsv3 = rsv3 === VOID ? false : rsv3; Frame.call(this, fin, FrameType_BINARY_getInstance(), data, NonDisposableHandle_instance, rsv1, rsv2, rsv3); } function Text(fin, data, rsv1, rsv2, rsv3) { rsv1 = rsv1 === VOID ? false : rsv1; rsv2 = rsv2 === VOID ? false : rsv2; rsv3 = rsv3 === VOID ? false : rsv3; Frame.call(this, fin, FrameType_TEXT_getInstance(), data, NonDisposableHandle_instance, rsv1, rsv2, rsv3); } function Close(data) { Frame.call(this, true, FrameType_CLOSE_getInstance(), data, NonDisposableHandle_instance, false, false, false); } function Companion_1() { Companion_instance_1 = this; this.d26_1 = new Int8Array(0); } var Companion_instance_1; function Companion_getInstance_1() { if (Companion_instance_1 == null) new Companion_1(); return Companion_instance_1; } function Frame(fin, frameType, data, disposableHandle, rsv1, rsv2, rsv3) { Companion_getInstance_1(); disposableHandle = disposableHandle === VOID ? NonDisposableHandle_instance : disposableHandle; rsv1 = rsv1 === VOID ? false : rsv1; rsv2 = rsv2 === VOID ? false : rsv2; rsv3 = rsv3 === VOID ? false : rsv3; this.e26_1 = fin; this.f26_1 = frameType; this.g26_1 = data; this.h26_1 = disposableHandle; this.i26_1 = rsv1; this.j26_1 = rsv2; this.k26_1 = rsv3; } protoOf(Frame).toString = function () { return 'Frame ' + this.f26_1.toString() + ' (fin=' + this.e26_1 + ', buffer len = ' + this.g26_1.length + ')'; }; //region block: init NonDisposableHandle_instance = new NonDisposableHandle(); //endregion //region block: exports _.$_$ = _.$_$ || {}; _.$_$.a = Codes_CLOSED_ABNORMALLY_getInstance; _.$_$.b = Codes_NORMAL_getInstance; _.$_$.c = Binary_init_$Create$; _.$_$.d = Close_init_$Create$; _.$_$.e = Text_init_$Create$; _.$_$.f = Companion_getInstance; _.$_$.g = CloseReason; //endregion return _; })); //# sourceMappingURL=ktor-ktor-websockets.js.map