diff --git a/extensions/THNK_GeckosClient.json b/extensions/THNK_GeckosClient.json new file mode 100644 index 0000000..c31d09e --- /dev/null +++ b/extensions/THNK_GeckosClient.json @@ -0,0 +1,96 @@ +{ + "author": "", + "category": "Network", + "description": "A THNK client adapter for networking via [geckos.io](https://geckos.io), a client-server netwroking solution that uses fast UDP and encrypted connections.", + "extensionNamespace": "", + "fullName": "THNK Geckos.io Client adapter", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWxhbi1jb25uZWN0IiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTQsMUMyLjg5LDEgMiwxLjg5IDIsM1Y3QzIsOC4xMSAyLjg5LDkgNCw5SDFWMTFIMTNWOUgxMEMxMS4xMSw5IDEyLDguMTEgMTIsN1YzQzEyLDEuODkgMTEuMTEsMSAxMCwxSDRNNCwzSDEwVjdINFYzTTMsMTNWMThMMywyMEgxMFYxOEg1VjEzSDNNMTQsMTNDMTIuODksMTMgMTIsMTMuODkgMTIsMTVWMTlDMTIsMjAuMTEgMTIuODksMjEgMTQsMjFIMTFWMjNIMjNWMjFIMjBDMjEuMTEsMjEgMjIsMjAuMTEgMjIsMTlWMTVDMjIsMTMuODkgMjEuMTEsMTMgMjAsMTNIMTRNMTQsMTVIMjBWMTlIMTRWMTVaIiAvPjwvc3ZnPg==", + "name": "THNK_GeckosClient", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/lan-connect.svg", + "shortDescription": "A THNK client adapter for networking via geckos.io", + "version": "1.0.0", + "tags": [ + "THNK", + "adapter", + "client", + "gecko", + "io" + ], + "authorIds": [ + "ZgrsWuRTAkXgeuPV9bo0zuEcA2w1" + ], + "dependencies": [ + { + "exportName": "@geckos.io/server", + "name": "Geckos server", + "type": "npm", + "version": "^2.2.3" + } + ], + "eventsFunctions": [ + { + "description": "", + "fullName": "", + "functionType": "Action", + "group": "", + "name": "onFirstSceneLoaded", + "private": false, + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": "// Load THNK Geckos Client Adapter (https://github.com/arthuro555/THNK)\n\"use strict\";\n(() => {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __commonJS = (cb, mod) => function __require() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n ));\n\n // node_modules/@yandeu/events/cjs/version.js\n var require_version = __commonJS({\n \"node_modules/@yandeu/events/cjs/version.js\"(exports) {\n \"use strict\";\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.VERSION = void 0;\n exports.VERSION = \"0.0.5\";\n }\n });\n\n // node_modules/@yandeu/events/cjs/index.js\n var require_cjs = __commonJS({\n \"node_modules/@yandeu/events/cjs/index.js\"(exports) {\n \"use strict\";\n var __spreadArray = exports && exports.__spreadArray || function(to, from) {\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\n to[j] = from[i];\n return to;\n };\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.Events = void 0;\n var version_1 = require_version();\n var EE = function() {\n function EE2(fn, context, once) {\n if (once === void 0) {\n once = false;\n }\n this.fn = fn;\n this.context = context;\n this.once = once;\n }\n return EE2;\n }();\n var addListener = function(emitter, event, fn, context, once) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\"The listener must be a function\");\n }\n var listener = new EE(fn, context || emitter, once);\n if (!emitter._events.has(event))\n emitter._events.set(event, listener), emitter._eventsCount++;\n else if (!emitter._events.get(event).fn)\n emitter._events.get(event).push(listener);\n else\n emitter._events.set(event, [emitter._events.get(event), listener]);\n return emitter;\n };\n var clearEvent = function(emitter, event) {\n if (--emitter._eventsCount === 0)\n emitter._events = /* @__PURE__ */ new Map();\n else\n emitter._events.delete(event);\n };\n var Events2 = function() {\n function Events3() {\n this._events = /* @__PURE__ */ new Map();\n this._eventsCount = 0;\n }\n Object.defineProperty(Events3, \"VERSION\", {\n get: function() {\n return version_1.VERSION;\n },\n enumerable: false,\n configurable: true\n });\n Events3.prototype.eventNames = function() {\n return Array.from(this._events.keys());\n };\n Events3.prototype.listeners = function(event) {\n var handlers = this._events.get(event);\n if (!handlers)\n return [];\n if (handlers.fn)\n return [handlers.fn];\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n return ee;\n };\n Events3.prototype.listenerCount = function(event) {\n var listeners = this._events.get(event);\n if (!listeners)\n return 0;\n if (listeners.fn)\n return 1;\n return listeners.length;\n };\n Events3.prototype.emit = function(event) {\n var _a, _b;\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n if (!this._events.has(event))\n return false;\n var listeners = this._events.get(event);\n var i;\n if (listeners.fn) {\n if (listeners.once)\n this.removeListener(event, listeners.fn, void 0, true);\n return (_a = listeners.fn).call.apply(_a, __spreadArray([listeners.context], args)), true;\n } else {\n var length_1 = listeners.length;\n for (i = 0; i < length_1; i++) {\n if (listeners[i].once)\n this.removeListener(event, listeners[i].fn, void 0, true);\n (_b = listeners[i].fn).call.apply(_b, __spreadArray([listeners[i].context], args));\n }\n }\n return true;\n };\n Events3.prototype.on = function(event, fn, context) {\n return addListener(this, event, fn, context, false);\n };\n Events3.prototype.once = function(event, fn, context) {\n return addListener(this, event, fn, context, true);\n };\n Events3.prototype.removeListener = function(event, fn, context, once) {\n if (!this._events.has(event))\n return this;\n if (!fn) {\n clearEvent(this, event);\n return this;\n }\n var listeners = this._events.get(event);\n if (listeners.fn) {\n if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {\n clearEvent(this, event);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {\n events.push(listeners[i]);\n }\n }\n if (events.length)\n this._events.set(event, events.length === 1 ? events[0] : events);\n else\n clearEvent(this, event);\n }\n return this;\n };\n Events3.prototype.removeAllListeners = function(event) {\n if (event) {\n if (this._events.delete(event))\n clearEvent(this, event);\n } else {\n this._events = /* @__PURE__ */ new Map();\n this._eventsCount = 0;\n }\n return this;\n };\n Object.defineProperty(Events3.prototype, \"off\", {\n get: function() {\n return this.removeListener;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Events3.prototype, \"addListener\", {\n get: function() {\n return this.on;\n },\n enumerable: false,\n configurable: true\n });\n return Events3;\n }();\n exports.Events = Events2;\n }\n });\n\n // node_modules/@geckos.io/common/lib/bridge.js\n var import_events = __toESM(require_cjs(), 1);\n var Bridge = class {\n constructor() {\n this.eventEmitter = new import_events.Events();\n }\n emit(eventName, data, connection = {}) {\n this.eventEmitter.emit(eventName, data, connection);\n }\n on(eventName, cb) {\n return this.eventEmitter.on(eventName, (data, options) => {\n cb(data, options);\n });\n }\n removeAllListeners() {\n this.eventEmitter.removeAllListeners();\n }\n };\n var bridge = new Bridge();\n\n // node_modules/@geckos.io/common/lib/constants.js\n var EVENTS = {\n CONNECT: \"connect\",\n CONNECTION: \"connection\",\n DATA_CHANNEL_IS_OPEN: \"dataChannelIsOpen\",\n DISCONNECT: \"disconnect\",\n DISCONNECTED: \"disconnected\",\n DROP: \"dropped\",\n ERROR: \"error\",\n RAW_MESSAGE: \"rawMessage\",\n RECEIVED_FROM_DATA_CHANNEL: \"receiveFromDataChannel\",\n SEND_OVER_DATA_CHANNEL: \"sendOverDataChannel\"\n };\n var ERRORS = {\n BROWSER_NOT_SUPPORTED: \"BROWSER_NOT_SUPPORTED\",\n COULD_NOT_PARSE_MESSAGE: \"COULD_NOT_PARSE_MESSAGE\",\n DROPPED_FROM_BUFFERING: \"DROPPED_FROM_BUFFERING\",\n MAX_MESSAGE_SIZE_EXCEEDED: \"MAX_MESSAGE_SIZE_EXCEEDED\"\n };\n\n // node_modules/@geckos.io/common/lib/types.js\n var ArrayBufferView = Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array())).constructor;\n\n // node_modules/@geckos.io/common/lib/helpers.js\n var tick = typeof Promise == \"function\" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;\n var isStringMessage = (data) => {\n return typeof data === \"string\";\n };\n var isBufferMessage = (data) => {\n return data instanceof ArrayBuffer || data instanceof ArrayBufferView;\n };\n var isJSONMessage = (data) => {\n try {\n if (typeof data !== \"string\")\n return false;\n if (!isNaN(parseInt(data)))\n return false;\n JSON.parse(data);\n return true;\n } catch (error) {\n return false;\n }\n };\n\n // node_modules/@geckos.io/common/lib/parseMessage.js\n var ParseMessage = (ev) => {\n let { data } = ev;\n if (!data)\n data = ev;\n const isBuffer = isBufferMessage(data);\n const isJson = isJSONMessage(data);\n const isString = isStringMessage(data);\n if (isJson) {\n const object = JSON.parse(data);\n const key = Object.keys(object)[0];\n const value = object[key];\n return { key, data: value };\n }\n if (isBuffer) {\n return { key: EVENTS.RAW_MESSAGE, data };\n }\n if (isString) {\n return { key: EVENTS.RAW_MESSAGE, data };\n }\n return { key: \"error\", data: new Error(ERRORS.COULD_NOT_PARSE_MESSAGE) };\n };\n var parseMessage_default = ParseMessage;\n\n // node_modules/@geckos.io/common/lib/sendMessage.js\n var SendMessage = (dataChannel, maxMessageSize, eventName, data = null) => {\n var _a;\n const send = (data2, isBuffer) => {\n var _a2;\n const bytes = (_a2 = data2.byteLength) !== null && _a2 !== void 0 ? _a2 : data2.length * 2;\n if (typeof maxMessageSize === \"number\" && bytes > maxMessageSize) {\n throw new Error(`maxMessageSize of ${maxMessageSize} exceeded`);\n } else {\n Promise.resolve().then(() => {\n if (dataChannel.send)\n dataChannel.send(data2);\n else {\n if (!isBuffer)\n dataChannel.sendMessage(data2);\n else\n dataChannel.sendMessageBinary(Buffer.from(data2));\n }\n }).catch((error) => {\n console.log(\"error\", error);\n });\n }\n };\n if (!dataChannel)\n return;\n if (dataChannel.readyState === \"open\" || ((_a = dataChannel.isOpen) === null || _a === void 0 ? void 0 : _a.call(dataChannel))) {\n try {\n if (eventName === EVENTS.RAW_MESSAGE && data !== null && (isStringMessage(data) || isBufferMessage(data))) {\n send(data, isBufferMessage(data));\n } else {\n send(JSON.stringify({ [eventName]: data }), false);\n }\n } catch (error) {\n console.error(\"Error in sendMessage.ts: \", error.message);\n return error;\n }\n }\n };\n var sendMessage_default = SendMessage;\n\n // node_modules/@geckos.io/client/lib/wrtc/connectionsManager.js\n var ConnectionsManagerClient = class {\n constructor(url, authorization, label, rtcConfiguration) {\n this.url = url;\n this.authorization = authorization;\n this.label = label;\n this.rtcConfiguration = rtcConfiguration;\n this.bridge = new Bridge();\n this.onDataChannel = (ev) => {\n const { channel } = ev;\n if (channel.label !== this.label)\n return;\n this.dataChannel = channel;\n this.dataChannel.binaryType = \"arraybuffer\";\n this.dataChannel.onmessage = (ev2) => {\n const { key, data } = parseMessage_default(ev2);\n this.bridge.emit(key, data);\n };\n };\n }\n emit(eventName, data = null) {\n sendMessage_default(this.dataChannel, this.maxMessageSize, eventName, data);\n }\n async fetchAdditionalCandidates(host, id) {\n var _a;\n if (((_a = this.dataChannel) === null || _a === void 0 ? void 0 : _a.readyState) === \"closed\")\n return;\n const res = await fetch(`${host}/connections/${id}/additional-candidates`, {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n if (res.ok) {\n const candidates = await res.json();\n candidates.forEach((c) => {\n this.localPeerConnection.addIceCandidate(c);\n });\n }\n }\n async connect() {\n const host = `${this.url}/.wrtc/v2`;\n let headers = { \"Content-Type\": \"application/json\" };\n if (this.authorization)\n headers = { ...headers, [\"Authorization\"]: this.authorization };\n let userData = {};\n try {\n const res = await fetch(`${host}/connections`, {\n method: \"POST\",\n headers\n });\n if (res.status >= 300) {\n throw {\n name: \"Error\",\n message: `Connection failed with status code ${res.status}.`,\n status: res.status,\n statusText: res.statusText\n };\n }\n const json = await res.json();\n userData = json.userData;\n this.remotePeerConnection = json;\n } catch (error) {\n console.error(error.message);\n return { error };\n }\n const { id, localDescription } = this.remotePeerConnection;\n const configuration = {\n sdpSemantics: \"unified-plan\",\n ...this.rtcConfiguration\n };\n const RTCPc = RTCPeerConnection || webkitRTCPeerConnection;\n this.localPeerConnection = new RTCPc(configuration);\n const showBackOffIntervals = (attempts = 10, initial = 50, factor = 1.8, jitter = 20) => Array(attempts).fill(0).map((_, index) => parseInt((initial * factor ** index).toString()) + parseInt((Math.random() * jitter).toString()));\n showBackOffIntervals().forEach((ms) => {\n setTimeout(() => {\n this.fetchAdditionalCandidates(host, id).catch(() => {\n });\n }, ms);\n });\n try {\n await this.localPeerConnection.setRemoteDescription(localDescription);\n this.localPeerConnection.addEventListener(\"datachannel\", this.onDataChannel, { once: true });\n const originalAnswer = await this.localPeerConnection.createAnswer();\n const updatedAnswer = new RTCSessionDescription({\n type: \"answer\",\n sdp: originalAnswer.sdp\n });\n await this.localPeerConnection.setLocalDescription(updatedAnswer);\n try {\n await fetch(`${host}/connections/${id}/remote-description`, {\n method: \"POST\",\n body: JSON.stringify(this.localPeerConnection.localDescription),\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n } catch (error) {\n console.error(error.message);\n return { error };\n }\n const waitForDataChannel = () => {\n return new Promise((resolve) => {\n this.localPeerConnection.addEventListener(\"datachannel\", () => {\n resolve();\n }, { once: true });\n });\n };\n if (!this.dataChannel)\n await waitForDataChannel();\n return {\n userData,\n localPeerConnection: this.localPeerConnection,\n dataChannel: this.dataChannel,\n id\n };\n } catch (error) {\n console.error(error.message);\n this.localPeerConnection.close();\n return { error };\n }\n }\n };\n\n // node_modules/@geckos.io/client/lib/wrtc/peerConnection.js\n var PeerConnection = class {\n async connect(connectionsManager) {\n const webRTCPcSupported = RTCPeerConnection || webkitRTCPeerConnection;\n if (webRTCPcSupported) {\n const { localPeerConnection, dataChannel, id, userData, error } = await connectionsManager.connect();\n if (error)\n return { error };\n if (!localPeerConnection || !dataChannel || !id || !userData)\n return { error: new Error('Something went wrong in \"await connectionsManager.connect()\"') };\n this.localPeerConnection = localPeerConnection;\n this.dataChannel = dataChannel;\n this.id = id;\n return { userData };\n } else {\n const error = new Error(ERRORS.BROWSER_NOT_SUPPORTED);\n console.error(error.message);\n return { error };\n }\n }\n };\n\n // node_modules/@geckos.io/common/lib/makeRandomId.js\n var makeRandomId = (length = 24) => {\n const possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n let id = \"\";\n for (let i = 0; i < length; i++) {\n id += possible.charAt(Math.floor(Math.random() * possible.length));\n }\n return id;\n };\n var makeRandomId_default = makeRandomId;\n\n // node_modules/@geckos.io/common/lib/runInterval.js\n var runInterval = (interval = 200, runs = 1, cb) => {\n let counter = 0;\n if (typeof cb !== \"function\") {\n console.error(\"You have to define your callback function!\");\n return;\n }\n const i = setInterval(() => {\n cb();\n counter++;\n if (counter === runs - 1) {\n clearInterval(i);\n }\n }, interval);\n cb();\n };\n var runInterval_default = runInterval;\n\n // node_modules/@geckos.io/common/lib/reliableMessage.js\n var makeReliable = (options, cb) => {\n const { interval = 150, runs = 10 } = options;\n const id = makeRandomId_default(24);\n runInterval_default(interval, runs, () => {\n cb(id);\n });\n };\n\n // node_modules/@geckos.io/client/lib/geckos/channel.js\n var ClientChannel = class {\n constructor(url, authorization, port, label, rtcConfiguration) {\n this.userData = {};\n this.receivedReliableMessages = [];\n this.url = port ? `${url}:${port}` : url;\n this.connectionsManager = new ConnectionsManagerClient(this.url, authorization, label, rtcConfiguration);\n this.bridge = this.connectionsManager.bridge;\n this.bridge.on(EVENTS.DISCONNECTED, () => this.bridge.removeAllListeners());\n }\n onconnectionstatechange() {\n const lpc = this.peerConnection.localPeerConnection;\n lpc.onconnectionstatechange = () => {\n if (lpc.connectionState === \"disconnected\" || lpc.connectionState === \"closed\")\n this.bridge.emit(EVENTS.DISCONNECTED);\n };\n }\n get id() {\n return this.peerConnection.id;\n }\n close() {\n this.peerConnection.localPeerConnection.close();\n this.bridge.emit(EVENTS.DISCONNECTED);\n try {\n const host = `${this.url}/.wrtc/v2`;\n fetch(`${host}/connections/${this.id}/close`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n }\n });\n } catch (error) {\n console.error(error.message);\n }\n }\n emit(eventName, data = null, options) {\n if (options && options.reliable) {\n makeReliable(options, (id) => this.connectionsManager.emit(eventName, {\n MESSAGE: data,\n RELIABLE: 1,\n ID: id\n }));\n } else {\n this.connectionsManager.emit(eventName, data);\n }\n }\n get raw() {\n return {\n emit: (rawMessage) => this.emit(EVENTS.RAW_MESSAGE, rawMessage)\n };\n }\n onRaw(callback) {\n this.bridge.on(EVENTS.RAW_MESSAGE, (rawMessage) => {\n const cb = (rawMessage2) => callback(rawMessage2);\n cb(rawMessage);\n });\n }\n async onConnect(callback) {\n var _a;\n this.peerConnection = new PeerConnection();\n const response = await this.peerConnection.connect(this.connectionsManager);\n if (response.error)\n callback(response.error);\n else {\n if (response.userData)\n this.userData = response.userData;\n this.maxMessageSize = this.connectionsManager.maxMessageSize = (_a = this.peerConnection.localPeerConnection.sctp) === null || _a === void 0 ? void 0 : _a.maxMessageSize;\n this.onconnectionstatechange();\n callback();\n }\n }\n onDisconnect(callback) {\n this.bridge.on(EVENTS.DISCONNECTED, callback);\n }\n on(eventName, callback) {\n this.bridge.on(eventName, (data) => {\n const isReliableMessage = data && data.RELIABLE === 1 && data.ID !== \"undefined\";\n const expireTime = 15e3;\n const deleteExpiredReliableMessages = () => {\n const currentTime = new Date().getTime();\n this.receivedReliableMessages.forEach((msg, index, object) => {\n if (msg.expire <= currentTime) {\n object.splice(index, 1);\n }\n });\n };\n if (isReliableMessage) {\n deleteExpiredReliableMessages();\n if (this.receivedReliableMessages.filter((obj) => obj.id === data.ID).length === 0) {\n this.receivedReliableMessages.push({\n id: data.ID,\n timestamp: new Date(),\n expire: new Date().getTime() + expireTime\n });\n callback(data.MESSAGE);\n } else {\n }\n } else {\n callback(data);\n }\n });\n }\n };\n var geckosClient = (options = {}) => {\n const { authorization = void 0, iceServers = [], iceTransportPolicy = \"all\", label = \"geckos.io\", port = 9208, url = `${location.protocol}//${location.hostname}` } = options;\n return new ClientChannel(url, authorization, port, label, { iceServers, iceTransportPolicy });\n };\n var channel_default = geckosClient;\n\n // code/adapters/geckos-client.ts\n var logger = new gdjs.Logger(\"THNK - Geckos.io Adapter\");\n THNK.GeckosClientAdapter = class GeckosClientAdapter extends THNK.ClientAdapter {\n constructor(ip, port) {\n super();\n this.connection = null;\n this.ip = ip;\n this.port = port;\n }\n async prepare() {\n this.connection = channel_default({ url: this.ip, port: this.port, label: \"THNK\" });\n await new Promise(\n (resolve, reject) => this.connection.onConnect((error) => {\n if (error)\n return reject(error.message);\n this.connection.onRaw(\n (message) => this.onMessage(message)\n );\n this.connection.onDisconnect(() => this.onDisconnection());\n resolve();\n })\n );\n }\n close() {\n if (this.connection)\n this.connection.close();\n }\n doSendMessage(message) {\n if (!this.connection) {\n return logger.error(\n \"Tried to send a message on an unestablished connection!\"\n );\n }\n this.connection.raw.emit(\n message.buffer.slice(message.buffer.byteLength - message.byteLength)\n );\n }\n };\n})();\n/**\n * @package npmjs.com/package/@yandeu/events (events.min.js)\n *\n * @author Arnout Kazemier (https://github.com/3rd-Eden)\n * @copyright Copyright (c) 2014 Arnout Kazemier\n * @license {@link https://github.com/primus/eventemitter3/blob/master/LICENSE|MIT}\n *\n * @author Yannick Deubel (https://github.com/yandeu)\n * @copyright Copyright (c) 2021 Yannick Deubel; Project Url: https://github.com/yandeu/events\n * @license {@link https://github.com/yandeu/events/blob/master/LICENSE|MIT}\n */\n", + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [], + "objectGroups": [] + }, + { + "description": "Connects to a geckos.io THNK server.", + "fullName": "Connect to server", + "functionType": "Action", + "group": "", + "name": "ConnectToServer", + "private": false, + "sentence": "Connect to server at _PARAM1_:_PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": "THNK.client.startClient(\n runtimeScene,\n new THNK.GeckosClientAdapter(\n eventsFunctionContext.getArgument(\"Host\"),\n eventsFunctionContext.getArgument(\"Port\")\n )\n);\n", + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "parameters": [ + { + "codeOnly": false, + "defaultValue": "", + "description": "Hostname (URL or IP address)", + "longDescription": "", + "name": "Host", + "optional": false, + "supplementaryInformation": "", + "type": "string" + }, + { + "codeOnly": false, + "defaultValue": "", + "description": "The port the server is hosted on", + "longDescription": "", + "name": "Port", + "optional": false, + "supplementaryInformation": "", + "type": "expression" + } + ], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +} \ No newline at end of file diff --git a/extensions/THNK_GeckosServer.json b/extensions/THNK_GeckosServer.json index c3ad06e..0649b4a 100644 --- a/extensions/THNK_GeckosServer.json +++ b/extensions/THNK_GeckosServer.json @@ -34,7 +34,7 @@ "events": [ { "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": "// Load THNK Geckos Server Adapter (https://github.com/arthuro555/THNK)\n\"use strict\";var ft=Object.create;var xe=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var T=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var mt=(r,e,t,i)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of dt(e))!Et.call(r,s)&&s!==t&&xe(r,s,{get:()=>e[s],enumerable:!(i=lt(e,s))||i.enumerable});return r};var Te=(r,e,t)=>(t=r!=null?ft(pt(r)):{},mt(e||!r||!r.__esModule?xe(t,\"default\",{value:r,enumerable:!0}):t,r));var Ae=T((Yt,Pe)=>{var S=require(\"fs\"),Ct=require(\"util\"),W=require(\"path\"),_e=require(\"events\"),Ue=require(\"zlib\"),Be=require(\"stream\"),o={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSIGFIRST:80,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,MAXFILECOMMENT:65535,ENDL64HDR:20,ENDL64SIG:117853008,ENDL64SIGFIRST:80,ENDL64OFS:8,END64HDR:56,END64SIG:101075792,END64SIGFIRST:80,END64SUB:24,END64TOT:32,END64SIZ:40,END64OFF:48,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,FLG_ENC:0,FLG_COMP1:1,FLG_COMP2:2,FLG_DESC:4,FLG_ENH:8,FLG_STR:16,FLG_LNG:1024,FLG_MSK:4096,FLG_ENTRY_ENC:1,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535},G=function(r){let e,t,i,s,c,d,p=this,m=r.storeEntries!==!1?{}:null,a=r.file,l=r.nameEncoding?new TextDecoder(r.nameEncoding):null;C();function C(){r.fd?(e=r.fd,F()):S.open(a,\"r\",(n,h)=>{if(n)return p.emit(\"error\",n);e=h,F()})}function F(){S.fstat(e,(n,h)=>{if(n)return p.emit(\"error\",n);t=h.size,i=r.chunkSize||Math.round(t/1e3),i=Math.max(Math.min(i,Math.min(128*1024,t)),Math.min(1024,t)),N()})}function y(n,h){if(n||!h)return p.emit(\"error\",n||new Error(\"Archive read error\"));let f=s.lastPos,u=f-s.win.position,g=s.win.buffer,E=s.minPos;for(;--f>=E&&--u>=0;)if(g.length-u>=4&&g[u]===s.firstByte&&g.readUInt32LE(u)===s.sig){s.lastBufferPosition=u,s.lastBytesRead=h,s.complete();return}if(f===E)return p.emit(\"error\",new Error(\"Bad archive\"));if(s.lastPos=f+1,s.chunkSize*=2,f<=E)return p.emit(\"error\",new Error(\"Bad archive\"));let _=Math.min(s.chunkSize,f-E);s.win.expandLeft(_,y)}function N(){let n=Math.min(o.ENDHDR+o.MAXFILECOMMENT,t);s={win:new ne(e),totalReadLength:n,minPos:t-n,lastPos:t,chunkSize:Math.min(1024,i),firstByte:o.ENDSIGFIRST,sig:o.ENDSIG,complete:R},s.win.read(t-s.chunkSize,s.chunkSize,y)}function R(){let n=s.win.buffer,h=s.lastBufferPosition;try{c=new pe,c.read(n.slice(h,h+o.ENDHDR)),c.headerOffset=s.win.position+h,c.commentLength?p.comment=n.slice(h+o.ENDHDR,h+o.ENDHDR+c.commentLength).toString():p.comment=null,p.entriesCount=c.volumeEntries,p.centralDirectory=c,c.volumeEntries===o.EF_ZIP64_OR_16&&c.totalEntries===o.EF_ZIP64_OR_16||c.size===o.EF_ZIP64_OR_32||c.offset===o.EF_ZIP64_OR_32?U():(s={},H())}catch(f){p.emit(\"error\",f)}}function U(){let n=o.ENDL64HDR;s.lastBufferPosition>n?(s.lastBufferPosition-=n,k()):(s={win:s.win,totalReadLength:n,minPos:s.win.position-n,lastPos:s.win.position,chunkSize:s.chunkSize,firstByte:o.ENDL64SIGFIRST,sig:o.ENDL64SIG,complete:k},s.win.read(s.lastPos-s.chunkSize,s.chunkSize,y))}function k(){let n=s.win.buffer,h=new Ee;h.read(n.slice(s.lastBufferPosition,s.lastBufferPosition+o.ENDL64HDR));let f=t-h.headerOffset;s={win:s.win,totalReadLength:f,minPos:h.headerOffset,lastPos:s.lastPos,chunkSize:s.chunkSize,firstByte:o.END64SIGFIRST,sig:o.END64SIG,complete:fe},s.win.read(t-s.chunkSize,s.chunkSize,y)}function fe(){let n=s.win.buffer,h=new me;h.read(n.slice(s.lastBufferPosition,s.lastBufferPosition+o.END64HDR)),p.centralDirectory.volumeEntries=h.volumeEntries,p.centralDirectory.totalEntries=h.totalEntries,p.centralDirectory.size=h.size,p.centralDirectory.offset=h.offset,p.entriesCount=h.volumeEntries,s={},H()}function H(){s={win:new ne(e),pos:c.offset,chunkSize:i,entriesLeft:c.volumeEntries},s.win.read(s.pos,Math.min(i,t-s.pos),le)}function le(n,h){if(n||!h)return p.emit(\"error\",n||new Error(\"Entries read error\"));let f=s.pos-s.win.position,u=s.entry,g=s.win.buffer,E=g.length;try{for(;s.entriesLeft>0;){u||(u=new Ce,u.readHeader(g,f),u.headerOffset=s.win.position+f,s.entry=u,s.pos+=o.CENHDR,f+=o.CENHDR);let _=u.fnameLen+u.extraLen+u.comLen,v=_+(s.entriesLeft>1?o.CENHDR:0);if(E-f{if(f)return h(f);let g=ie(u),E=new ge(e,g,u.compressedSize);if(u.method!==o.STORED)if(u.method===o.DEFLATED)E=E.pipe(Ue.createInflateRaw());else return h(new Error(\"Unknown compression method: \"+u.method));J(u)&&(E=E.pipe(new we(E,u.crc,u.size))),h(null,E)},!1)},this.entryDataSync=function(n){let h=null;if(this.openEntry(n,(u,g)=>{h=u,n=g},!0),h)throw h;let f=Buffer.alloc(n.compressedSize);if(new B(e,f,0,n.compressedSize,ie(n),u=>{h=u}).read(!0),h)throw h;if(n.method!==o.STORED)if(n.method===o.DEFLATED||n.method===o.ENHANCED_DEFLATED)f=Ue.inflateRawSync(f);else throw new Error(\"Unknown compression method: \"+n.method);if(f.length!==n.size)throw new Error(\"Invalid size\");return J(n)&&new A(n.crc,n.size).data(f),f},this.openEntry=function(n,h,f){if(typeof n==\"string\"&&(Z(),n=m[n],!n))return h(new Error(\"Entry not found\"));if(!n.isFile)return h(new Error(\"Entry is not file\"));if(!e)return h(new Error(\"Archive closed\"));let u=Buffer.alloc(o.LOCHDR);new B(e,u,0,u.length,n.offset,g=>{if(g)return h(g);let E;try{n.readDataHeader(u),n.encrypted&&(E=new Error(\"Entry encrypted\"))}catch(_){E=_}h(E,n)}).read(f)};function ie(n){return n.offset+o.LOCHDR+n.fnameLen+n.extraLen}function J(n){return(n.flags&8)!==8}function Q(n,h,f){p.stream(n,(u,g)=>{if(u)f(u);else{let E,_;g.on(\"error\",v=>{_=v,E&&(g.unpipe(E),E.close(()=>{f(v)}))}),S.open(h,\"w\",(v,x)=>{if(v)return f(v);if(_){S.close(e,()=>{f(_)});return}E=S.createWriteStream(h,{fd:x}),E.on(\"finish\",()=>{p.emit(\"extract\",n,h),_||f()}),g.pipe(E)})}})}function Se(n,h,f){if(!h.length)return f();let u=h.shift();u=W.join(n,W.join(...u)),S.mkdir(u,{recursive:!0},g=>{if(g&&g.code!==\"EEXIST\")return f(g);Se(n,h,f)})}function de(n,h,f,u,g){if(!f.length)return u(null,g);let E=f.shift(),_=W.join(n,E.name.replace(h,\"\"));Q(E,_,v=>{if(v)return u(v,g);de(n,h,f,u,g+1)})}this.extract=function(n,h,f){let u=n||\"\";if(typeof n==\"string\"&&(n=this.entry(n),n?u=n.name:u.length&&u[u.length-1]!==\"/\"&&(u+=\"/\")),!n||n.isDirectory){let g=[],E=[],_={};for(let v in m)if(Object.prototype.hasOwnProperty.call(m,v)&&v.lastIndexOf(u,0)===0){let x=v.replace(u,\"\"),be=m[v];if(be.isFile&&(g.push(be),x=W.dirname(x)),x&&!_[x]&&x!==\".\"){_[x]=!0;let M=x.split(\"/\").filter(ee=>ee);for(M.length&&E.push(M);M.length>1;){M=M.slice(0,M.length-1);let ee=M.join(\"/\");if(_[ee]||ee===\".\")break;_[ee]=!0,E.push(M)}}}E.sort((v,x)=>v.length-x.length),E.length?Se(h,E,v=>{v?f(v):de(h,u,g,f,0)}):de(h,u,g,f,0)}else S.stat(h,(g,E)=>{E&&E.isDirectory()?Q(n,W.join(h,W.basename(n.name)),f):Q(n,h,f)})},this.close=function(n){d||!e?(d=!0,n&&n()):(d=!0,S.close(e,h=>{e=null,n&&n(h)}))};let ut=_e.EventEmitter.prototype.emit;this.emit=function(...n){if(!d)return ut.call(this,...n)}};G.setFs=function(r){S=r};G.debugLog=(...r)=>{G.debug&&console.log(...r)};Ct.inherits(G,_e.EventEmitter);var z=Symbol(\"zip\");G.async=class extends _e.EventEmitter{constructor(e){super();let t=new G(e);t.on(\"entry\",i=>this.emit(\"entry\",i)),t.on(\"extract\",(i,s)=>this.emit(\"extract\",i,s)),this[z]=new Promise((i,s)=>{t.on(\"ready\",()=>{t.removeListener(\"error\",s),i(t)}),t.on(\"error\",s)})}get entriesCount(){return this[z].then(e=>e.entriesCount)}get comment(){return this[z].then(e=>e.comment)}async entry(e){return(await this[z]).entry(e)}async entries(){return(await this[z]).entries()}async stream(e){let t=await this[z];return new Promise((i,s)=>{t.stream(e,(c,d)=>{c?s(c):i(d)})})}async entryData(e){let t=await this.stream(e);return new Promise((i,s)=>{let c=[];t.on(\"data\",d=>c.push(d)),t.on(\"end\",()=>{i(Buffer.concat(c))}),t.on(\"error\",d=>{t.removeAllListeners(\"end\"),s(d)})})}async extract(e,t){let i=await this[z];return new Promise((s,c)=>{i.extract(e,t,(d,w)=>{d?c(d):s(w)})})}async close(){let e=await this[z];return new Promise((t,i)=>{e.close(s=>{s?i(s):t()})})}};var pe=class{read(e){if(e.length!==o.ENDHDR||e.readUInt32LE(0)!==o.ENDSIG)throw new Error(\"Invalid central directory\");this.volumeEntries=e.readUInt16LE(o.ENDSUB),this.totalEntries=e.readUInt16LE(o.ENDTOT),this.size=e.readUInt32LE(o.ENDSIZ),this.offset=e.readUInt32LE(o.ENDOFF),this.commentLength=e.readUInt16LE(o.ENDCOM)}},Ee=class{read(e){if(e.length!==o.ENDL64HDR||e.readUInt32LE(0)!==o.ENDL64SIG)throw new Error(\"Invalid zip64 central directory locator\");this.headerOffset=P(e,o.ENDSUB)}},me=class{read(e){if(e.length!==o.END64HDR||e.readUInt32LE(0)!==o.END64SIG)throw new Error(\"Invalid central directory\");this.volumeEntries=P(e,o.END64SUB),this.totalEntries=P(e,o.END64TOT),this.size=P(e,o.END64SIZ),this.offset=P(e,o.END64OFF)}},Ce=class{readHeader(e,t){if(e.length=8&&this.size===o.EF_ZIP64_OR_32&&(this.size=P(e,t),t+=8,i-=8),i>=8&&this.compressedSize===o.EF_ZIP64_OR_32&&(this.compressedSize=P(e,t),t+=8,i-=8),i>=8&&this.offset===o.EF_ZIP64_OR_32&&(this.offset=P(e,t),t+=8,i-=8),i>=4&&this.diskStart===o.EF_ZIP64_OR_16&&(this.diskStart=e.readUInt32LE(t))}get encrypted(){return(this.flags&o.FLG_ENTRY_ENC)===o.FLG_ENTRY_ENC}get isFile(){return!this.isDirectory}},B=class{constructor(e,t,i,s,c,d){this.fd=e,this.buffer=t,this.offset=i,this.length=s,this.position=c,this.callback=d,this.bytesRead=0,this.waiting=!1}read(e){G.debugLog(\"read\",this.position,this.bytesRead,this.length,this.offset),this.waiting=!0;let t;if(e){let i=0;try{i=S.readSync(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead)}catch(s){t=s}this.readCallback(e,t,t?i:null)}else S.read(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead,this.readCallback.bind(this,e))}readCallback(e,t,i){if(typeof i==\"number\"&&(this.bytesRead+=i),t||!i||this.bytesRead===this.length)return this.waiting=!1,this.callback(t,this.bytesRead);this.read(e)}},ne=class{constructor(e){this.position=0,this.buffer=Buffer.alloc(0),this.fd=e,this.fsOp=null}checkOp(){if(this.fsOp&&this.fsOp.waiting)throw new Error(\"Operation in progress\")}read(e,t,i){this.checkOp(),this.buffer.length{this.emit(\"error\",s)})}_transform(e,t,i){let s;try{this.verify.data(e)}catch(c){s=c}i(s,e)}},A=class{constructor(e,t){this.crc=e,this.size=t,this.state={crc:-1,size:0}}data(e){let t=A.getCrcTable(),i=this.state.crc,s=0,c=e.length;for(;--c>=0;)i=t[(i^e[s++])&255]^i>>>8;if(this.state.crc=i,this.state.size+=e.length,this.state.size>=this.size){let d=Buffer.alloc(4);if(d.writeInt32LE(~this.state.crc&4294967295,0),i=d.readUInt32LE(0),i!==this.crc)throw new Error(\"Invalid CRC\");if(this.state.size!==this.size)throw new Error(\"Invalid size\")}}static getCrcTable(){let e=A.crcTable;if(!e){A.crcTable=e=[];let t=Buffer.alloc(4);for(let i=0;i<256;i++){let s=i;for(let c=8;--c>=0;)(s&1)!==0?s=3988292384^s>>>1:s=s>>>1;s<0&&(t.writeInt32LE(s,0),s=t.readUInt32LE(0)),e[i]=s}}return e}};function Me(r,e){let t=ze(r,16),i=ze(e,16),s={h:parseInt(t.slice(0,5).join(\"\"),2),m:parseInt(t.slice(5,11).join(\"\"),2),s:parseInt(t.slice(11,16).join(\"\"),2)*2,Y:parseInt(i.slice(0,7).join(\"\"),2)+1980,M:parseInt(i.slice(7,11).join(\"\"),2),D:parseInt(i.slice(11,16).join(\"\"),2)},c=[s.Y,s.M,s.D].join(\"-\")+\" \"+[s.h,s.m,s.s].join(\":\")+\" GMT+0\";return new Date(c).getTime()}function ze(r,e){let t=(r>>>0).toString(2);for(;t.length{var K=1e3,V=K*60,Y=V*60,j=Y*24,gt=j*7,wt=j*365.25;Ge.exports=function(r,e){e=e||{};var t=typeof r;if(t===\"string\"&&r.length>0)return _t(r);if(t===\"number\"&&isFinite(r))return e.long?Lt(r):vt(r);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(r))};function _t(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!!e){var t=parseFloat(e[1]),i=(e[2]||\"ms\").toLowerCase();switch(i){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return t*wt;case\"weeks\":case\"week\":case\"w\":return t*gt;case\"days\":case\"day\":case\"d\":return t*j;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return t*Y;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return t*V;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return t*K;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return t;default:return}}}}function vt(r){var e=Math.abs(r);return e>=j?Math.round(r/j)+\"d\":e>=Y?Math.round(r/Y)+\"h\":e>=V?Math.round(r/V)+\"m\":e>=K?Math.round(r/K)+\"s\":r+\"ms\"}function Lt(r){var e=Math.abs(r);return e>=j?oe(r,e,j,\"day\"):e>=Y?oe(r,e,Y,\"hour\"):e>=V?oe(r,e,V,\"minute\"):e>=K?oe(r,e,K,\"second\"):r+\" ms\"}function oe(r,e,t,i){var s=e>=t*1.5;return Math.round(r/t)+\" \"+i+(s?\"s\":\"\")}});var ve=T((Qt,ke)=>{function It(r){t.debug=t,t.default=t,t.coerce=p,t.disable=c,t.enable=s,t.enabled=d,t.humanize=qe(),t.destroy=m,Object.keys(r).forEach(a=>{t[a]=r[a]}),t.names=[],t.skips=[],t.formatters={};function e(a){let l=0;for(let C=0;C{if(Z===\"%%\")return\"%\";H++;let J=t.formatters[ie];if(typeof J==\"function\"){let Q=R[H];Z=J.call(U,Q),R.splice(H,1),H--}return Z}),t.formatArgs.call(U,R),(U.log||t.log).apply(U,R)}return N.namespace=a,N.useColors=t.useColors(),N.color=t.selectColor(a),N.extend=i,N.destroy=t.destroy,Object.defineProperty(N,\"enabled\",{enumerable:!0,configurable:!1,get:()=>C!==null?C:(F!==t.namespaces&&(F=t.namespaces,y=t.enabled(a)),y),set:R=>{C=R}}),typeof t.init==\"function\"&&t.init(N),N}function i(a,l){let C=t(this.namespace+(typeof l>\"u\"?\":\":l)+a);return C.log=this.log,C}function s(a){t.save(a),t.namespaces=a,t.names=[],t.skips=[];let l,C=(typeof a==\"string\"?a:\"\").split(/[\\s,]+/),F=C.length;for(l=0;l\"-\"+l)].join(\",\");return t.enable(\"\"),a}function d(a){if(a[a.length-1]===\"*\")return!0;let l,C;for(l=0,C=t.skips.length;l{D.formatArgs=yt;D.save=Dt;D.load=Ot;D.useColors=Rt;D.storage=Ft();D.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})();D.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"];function Rt(){return typeof window<\"u\"&&window.process&&(window.process.type===\"renderer\"||window.process.__nwjs)?!0:typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)?!1:typeof document<\"u\"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<\"u\"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)}function yt(r){if(r[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+r[0]+(this.useColors?\"%c \":\" \")+\"+\"+ce.exports.humanize(this.diff),!this.useColors)return;let e=\"color: \"+this.color;r.splice(1,0,e,\"color: inherit\");let t=0,i=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!==\"%%\"&&(t++,s===\"%c\"&&(i=t))}),r.splice(i,0,e)}D.log=console.debug||console.log||(()=>{});function Dt(r){try{r?D.storage.setItem(\"debug\",r):D.storage.removeItem(\"debug\")}catch{}}function Ot(){let r;try{r=D.storage.getItem(\"debug\")}catch{}return!r&&typeof process<\"u\"&&\"env\"in process&&(r=process.env.DEBUG),r}function Ft(){try{return localStorage}catch{}}ce.exports=ve()(D);var{formatters:Nt}=ce.exports;Nt.j=function(r){try{return JSON.stringify(r)}catch(e){return\"[UnexpectedJSONParseError]: \"+e.message}}});var je=T((er,Ze)=>{\"use strict\";Ze.exports=(r,e=process.argv)=>{let t=r.startsWith(\"-\")?\"\":r.length===1?\"-\":\"--\",i=e.indexOf(t+r),s=e.indexOf(\"--\");return i!==-1&&(s===-1||i{\"use strict\";var St=require(\"os\"),Xe=require(\"tty\"),b=je(),{env:L}=process,q;b(\"no-color\")||b(\"no-colors\")||b(\"color=false\")||b(\"color=never\")?q=0:(b(\"color\")||b(\"colors\")||b(\"color=true\")||b(\"color=always\"))&&(q=1);\"FORCE_COLOR\"in L&&(L.FORCE_COLOR===\"true\"?q=1:L.FORCE_COLOR===\"false\"?q=0:q=L.FORCE_COLOR.length===0?1:Math.min(parseInt(L.FORCE_COLOR,10),3));function Le(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Ie(r,e){if(q===0)return 0;if(b(\"color=16m\")||b(\"color=full\")||b(\"color=truecolor\"))return 3;if(b(\"color=256\"))return 2;if(r&&!e&&q===void 0)return 0;let t=q||0;if(L.TERM===\"dumb\")return t;if(process.platform===\"win32\"){let i=St.release().split(\".\");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if(\"CI\"in L)return[\"TRAVIS\",\"CIRCLECI\",\"APPVEYOR\",\"GITLAB_CI\",\"GITHUB_ACTIONS\",\"BUILDKITE\"].some(i=>i in L)||L.CI_NAME===\"codeship\"?1:t;if(\"TEAMCITY_VERSION\"in L)return/^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(L.TEAMCITY_VERSION)?1:0;if(L.COLORTERM===\"truecolor\")return 3;if(\"TERM_PROGRAM\"in L){let i=parseInt((L.TERM_PROGRAM_VERSION||\"\").split(\".\")[0],10);switch(L.TERM_PROGRAM){case\"iTerm.app\":return i>=3?3:2;case\"Apple_Terminal\":return 2}}return/-256(color)?$/i.test(L.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(L.TERM)||\"COLORTERM\"in L?1:t}function bt(r){let e=Ie(r,r&&r.isTTY);return Le(e)}$e.exports={supportsColor:bt,stdout:Le(Ie(!0,Xe.isatty(1))),stderr:Le(Ie(!0,Xe.isatty(2)))}});var Ve=T((I,he)=>{var xt=require(\"tty\"),ae=require(\"util\");I.init=At;I.log=zt;I.formatArgs=Ut;I.save=Bt;I.load=Pt;I.useColors=Tt;I.destroy=ae.deprecate(()=>{},\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\");I.colors=[6,2,3,4,5,1];try{let r=We();r&&(r.stderr||r).level>=2&&(I.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}I.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,c)=>c.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i===\"null\"?i=null:i=Number(i),r[t]=i,r},{});function Tt(){return\"colors\"in I.inspectOpts?Boolean(I.inspectOpts.colors):xt.isatty(process.stderr.fd)}function Ut(r){let{namespace:e,useColors:t}=this;if(t){let i=this.color,s=\"\\x1B[3\"+(i<8?i:\"8;5;\"+i),c=` ${s};1m${e} \\x1B[0m`;r[0]=c+r[0].split(`\n`).join(`\n`+c),r.push(s+\"m+\"+he.exports.humanize(this.diff)+\"\\x1B[0m\")}else r[0]=Mt()+e+\" \"+r[0]}function Mt(){return I.inspectOpts.hideDate?\"\":new Date().toISOString()+\" \"}function zt(...r){return process.stderr.write(ae.format(...r)+`\n`)}function Bt(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Pt(){return process.env.DEBUG}function At(r){r.inspectOpts={};let e=Object.keys(I.inspectOpts);for(let t=0;te.trim()).join(\" \")};Ke.O=function(r){return this.inspectOpts.colors=this.useColors,ae.inspect(r,this.inspectOpts)}});var Ye=T((rr,Re)=>{typeof process>\"u\"||process.type===\"renderer\"||process.browser===!0||process.__nwjs?Re.exports=He():Re.exports=Ve()});var Qe=T((sr,Je)=>{var te;Je.exports=function(){if(!te){try{te=Ye()(\"follow-redirects\")}catch{}typeof te!=\"function\"&&(te=function(){})}te.apply(null,arguments)}});var ct=T((ir,Ne)=>{var X=require(\"url\"),ye=X.URL,Gt=require(\"http\"),qt=require(\"https\"),rt=require(\"stream\").Writable,st=require(\"assert\"),it=Qe(),Oe=[\"abort\",\"aborted\",\"connect\",\"error\",\"socket\",\"timeout\"],Fe=Object.create(null);Oe.forEach(function(r){Fe[r]=function(e,t,i){this._redirectable.emit(r,e,t,i)}});var kt=se(\"ERR_INVALID_URL\",\"Invalid URL\",TypeError),et=se(\"ERR_FR_REDIRECTION_FAILURE\",\"Redirected request failed\"),Ht=se(\"ERR_FR_TOO_MANY_REDIRECTS\",\"Maximum number of redirects exceeded\"),Zt=se(\"ERR_FR_MAX_BODY_LENGTH_EXCEEDED\",\"Request body larger than maxBodyLength limit\"),jt=se(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\");function O(r,e){rt.call(this),this._sanitizeOptions(r),this._options=r,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],e&&this.on(\"response\",e);var t=this;this._onNativeResponse=function(i){t._processResponse(i)},this._performRequest()}O.prototype=Object.create(rt.prototype);O.prototype.abort=function(){ot(this._currentRequest),this.emit(\"abort\")};O.prototype.write=function(r,e,t){if(this._ending)throw new jt;if(!$(r)&&!Wt(r))throw new TypeError(\"data should be a string, Buffer or Uint8Array\");if(re(e)&&(t=e,e=null),r.length===0){t&&t();return}this._requestBodyLength+r.length<=this._options.maxBodyLength?(this._requestBodyLength+=r.length,this._requestBodyBuffers.push({data:r,encoding:e}),this._currentRequest.write(r,e,t)):(this.emit(\"error\",new Zt),this.abort())};O.prototype.end=function(r,e,t){if(re(r)?(t=r,r=e=null):re(e)&&(t=e,e=null),!r)this._ended=this._ending=!0,this._currentRequest.end(null,null,t);else{var i=this,s=this._currentRequest;this.write(r,e,function(){i._ended=!0,s.end(null,null,t)}),this._ending=!0}};O.prototype.setHeader=function(r,e){this._options.headers[r]=e,this._currentRequest.setHeader(r,e)};O.prototype.removeHeader=function(r){delete this._options.headers[r],this._currentRequest.removeHeader(r)};O.prototype.setTimeout=function(r,e){var t=this;function i(d){d.setTimeout(r),d.removeListener(\"timeout\",d.destroy),d.addListener(\"timeout\",d.destroy)}function s(d){t._timeout&&clearTimeout(t._timeout),t._timeout=setTimeout(function(){t.emit(\"timeout\"),c()},r),i(d)}function c(){t._timeout&&(clearTimeout(t._timeout),t._timeout=null),t.removeListener(\"abort\",c),t.removeListener(\"error\",c),t.removeListener(\"response\",c),e&&t.removeListener(\"timeout\",e),t.socket||t._currentRequest.removeListener(\"socket\",s)}return e&&this.on(\"timeout\",e),this.socket?s(this.socket):this._currentRequest.once(\"socket\",s),this.on(\"socket\",i),this.on(\"abort\",c),this.on(\"error\",c),this.on(\"response\",c),this};[\"flushHeaders\",\"getHeader\",\"setNoDelay\",\"setSocketKeepAlive\"].forEach(function(r){O.prototype[r]=function(e,t){return this._currentRequest[r](e,t)}});[\"aborted\",\"connection\",\"socket\"].forEach(function(r){Object.defineProperty(O.prototype,r,{get:function(){return this._currentRequest[r]}})});O.prototype._sanitizeOptions=function(r){if(r.headers||(r.headers={}),r.host&&(r.hostname||(r.hostname=r.host),delete r.host),!r.pathname&&r.path){var e=r.path.indexOf(\"?\");e<0?r.pathname=r.path:(r.pathname=r.path.substring(0,e),r.search=r.path.substring(e))}};O.prototype._performRequest=function(){var r=this._options.protocol,e=this._options.nativeProtocols[r];if(!e){this.emit(\"error\",new TypeError(\"Unsupported protocol \"+r));return}if(this._options.agents){var t=r.slice(0,-1);this._options.agent=this._options.agents[t]}var i=this._currentRequest=e.request(this._options,this._onNativeResponse);i._redirectable=this;for(var s of Oe)i.on(s,Fe[s]);if(this._currentUrl=/^\\//.test(this._options.path)?X.format(this._options):this._options.path,this._isRedirect){var c=0,d=this,w=this._requestBodyBuffers;(function p(m){if(i===d._currentRequest)if(m)d.emit(\"error\",m);else if(c=400){r.responseUrl=this._currentUrl,r.redirects=this._redirects,this.emit(\"response\",r),this._requestBodyBuffers=[];return}if(ot(this._currentRequest),r.destroy(),++this._redirectCount>this._options.maxRedirects){this.emit(\"error\",new Ht);return}var i,s=this._options.beforeRedirect;s&&(i=Object.assign({Host:r.req.getHeader(\"host\")},this._options.headers));var c=this._options.method;((e===301||e===302)&&this._options.method===\"POST\"||e===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method=\"GET\",this._requestBodyBuffers=[],De(/^content-/i,this._options.headers));var d=De(/^host$/i,this._options.headers),w=X.parse(this._currentUrl),p=d||w.host,m=/^\\w+:/.test(t)?this._currentUrl:X.format(Object.assign(w,{host:p})),a;try{a=X.resolve(m,t)}catch(y){this.emit(\"error\",new et({cause:y}));return}it(\"redirecting to\",a),this._isRedirect=!0;var l=X.parse(a);if(Object.assign(this._options,l),(l.protocol!==w.protocol&&l.protocol!==\"https:\"||l.host!==p&&!$t(l.host,p))&&De(/^(?:authorization|cookie)$/i,this._options.headers),re(s)){var C={headers:r.headers,statusCode:e},F={url:m,method:c,headers:i};try{s(this._options,C,F)}catch(y){this.emit(\"error\",y);return}this._sanitizeOptions(this._options)}try{this._performRequest()}catch(y){this.emit(\"error\",new et({cause:y}))}};function nt(r){var e={maxRedirects:21,maxBodyLength:10485760},t={};return Object.keys(r).forEach(function(i){var s=i+\":\",c=t[s]=r[i],d=e[i]=Object.create(c);function w(m,a,l){if($(m)){var C;try{C=tt(new ye(m))}catch{C=X.parse(m)}if(!$(C.protocol))throw new kt({input:m});m=C}else ye&&m instanceof ye?m=tt(m):(l=a,a=m,m={protocol:s});return re(a)&&(l=a,a=null),a=Object.assign({maxRedirects:e.maxRedirects,maxBodyLength:e.maxBodyLength},m,a),a.nativeProtocols=t,!$(a.host)&&!$(a.hostname)&&(a.hostname=\"::1\"),st.equal(a.protocol,s,\"protocol mismatch\"),it(\"options\",a),new O(a,l)}function p(m,a,l){var C=d.request(m,a,l);return C.end(),C}Object.defineProperties(d,{request:{value:w,configurable:!0,enumerable:!0,writable:!0},get:{value:p,configurable:!0,enumerable:!0,writable:!0}})}),e}function Xt(){}function tt(r){var e={protocol:r.protocol,hostname:r.hostname.startsWith(\"[\")?r.hostname.slice(1,-1):r.hostname,hash:r.hash,search:r.search,pathname:r.pathname,path:r.pathname+r.search,href:r.href};return r.port!==\"\"&&(e.port=Number(r.port)),e}function De(r,e){var t;for(var i in e)r.test(i)&&(t=e[i],delete e[i]);return t===null||typeof t>\"u\"?void 0:String(t).trim()}function se(r,e,t){function i(s){Error.captureStackTrace(this,this.constructor),Object.assign(this,s||{}),this.code=r,this.message=this.cause?e+\": \"+this.cause.message:e}return i.prototype=new(t||Error),i.prototype.constructor=i,i.prototype.name=\"Error [\"+r+\"]\",i}function ot(r){for(var e of Oe)r.removeListener(e,Fe[e]);r.on(\"error\",Xt),r.abort()}function $t(r,e){st($(r)&&$(e));var t=r.length-e.length-1;return t>0&&r[t]===\".\"&&r.endsWith(e)}function $(r){return typeof r==\"string\"||r instanceof String}function re(r){return typeof r==\"function\"}function Wt(r){return typeof r==\"object\"&&\"length\"in r}Ne.exports=nt({http:Gt,https:qt});Ne.exports.wrap=nt});var at=Te(Ae()),ht=Te(ct()),ue=()=>Math.random().toFixed(Math.ceil(Math.random()*6)+2).slice(2);THNK.GeckosServerAdapter=class extends THNK.ServerAdapter{constructor(t,i){super();this.id=0;this.server=null;this.httpServer=null;this.channels=new Map;this.ip=t,this.port=i}async prepare(t){let i=t.getGame().getRenderer().getElectronRemote();if(!i)throw new Error(\"The game does not seem to be running on a desktop, impossible to launch geckos server!\");let s=i.require,c;if(!t.getGame().isPreview())c=s(\"@geckos.io/server\").geckos;else{let w=s(\"fs\");if(!w.existsSync(\"./geckos-server\")){console.info(\"Geckos server not found, downloading it now!\");let{https:{get:p}}=(0,ht.wrap)({https:s(\"https\")}),{pipeline:m}=s(\"stream/promises\"),a=await new Promise(C=>p(\"https://s3.arthuro555.com/geckos-server-electron.zip\",F=>C(F)));await m(a,w.createWriteStream(\"./geckos-server.zip\"));let l=new at.async({file:\"./geckos-server.zip\"});w.mkdirSync(\"./geckos-server\"),await l.extract(null,\"./geckos-server\"),await l.close()}c=s(process.cwd()+\"/geckos-server/index.js\").geckos}if(!c)throw new Error(\"Geckos not found!\");this.server=c({label:\"THNK\"}),this.server.onConnection(w=>{let p=`${ue()}-${this.id++}-${ue()}`;this.onConnection(p),this.channels.set(p,w),w.onRaw(m=>this.onMessage(p,m)),w.onDisconnect(()=>this.onDisconnection(p))}),this.httpServer=s(\"http\").createServer(),this.server.addServer(this.httpServer),this.httpServer.listen(this.port);let d=w=>{w.returnValue=\"false\",this.close(),window.removeEventListener(\"beforeunload\",d),window.close()};window.addEventListener(\"beforeunload\",d)}close(){if(this.server&&this.httpServer){this.httpServer.close(),this.httpServer.closeAllConnections&&this.httpServer.closeAllConnections();for(let t of this.channels.values())t.close();this.channels.clear(),this.httpServer=null,this.server=null}}doSendMessageTo(t,i){let s=this.channels.get(t);s&&s.raw.emit(i.buffer.slice(i.buffer.byteLength-i.byteLength))}getServerID(){return`${ue()}-server-${ue()}`}};\n/**\n * @license node-stream-zip | (c) 2020 Antelle | https://github.com/antelle/node-stream-zip/blob/master/LICENSE\n * Portions copyright https://github.com/cthackers/adm-zip | https://raw.githubusercontent.com/cthackers/adm-zip/master/LICENSE\n */\n", + "inlineCode": "// Load THNK Geckos Server Adapter (https://github.com/arthuro555/THNK)\n\"use strict\";var ft=Object.create;var xe=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var T=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var mt=(r,e,t,i)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of dt(e))!Et.call(r,s)&&s!==t&&xe(r,s,{get:()=>e[s],enumerable:!(i=lt(e,s))||i.enumerable});return r};var Te=(r,e,t)=>(t=r!=null?ft(pt(r)):{},mt(e||!r||!r.__esModule?xe(t,\"default\",{value:r,enumerable:!0}):t,r));var Ae=T((Yt,Pe)=>{var N=require(\"fs\"),Ct=require(\"util\"),W=require(\"path\"),_e=require(\"events\"),Ue=require(\"zlib\"),Be=require(\"stream\"),o={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSIGFIRST:80,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,MAXFILECOMMENT:65535,ENDL64HDR:20,ENDL64SIG:117853008,ENDL64SIGFIRST:80,ENDL64OFS:8,END64HDR:56,END64SIG:101075792,END64SIGFIRST:80,END64SUB:24,END64TOT:32,END64SIZ:40,END64OFF:48,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,FLG_ENC:0,FLG_COMP1:1,FLG_COMP2:2,FLG_DESC:4,FLG_ENH:8,FLG_STR:16,FLG_LNG:1024,FLG_MSK:4096,FLG_ENTRY_ENC:1,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535},G=function(r){let e,t,i,s,c,d,p=this,m=r.storeEntries!==!1?{}:null,a=r.file,l=r.nameEncoding?new TextDecoder(r.nameEncoding):null;C();function C(){r.fd?(e=r.fd,F()):N.open(a,\"r\",(n,h)=>{if(n)return p.emit(\"error\",n);e=h,F()})}function F(){N.fstat(e,(n,h)=>{if(n)return p.emit(\"error\",n);t=h.size,i=r.chunkSize||Math.round(t/1e3),i=Math.max(Math.min(i,Math.min(128*1024,t)),Math.min(1024,t)),S()})}function y(n,h){if(n||!h)return p.emit(\"error\",n||new Error(\"Archive read error\"));let f=s.lastPos,u=f-s.win.position,g=s.win.buffer,E=s.minPos;for(;--f>=E&&--u>=0;)if(g.length-u>=4&&g[u]===s.firstByte&&g.readUInt32LE(u)===s.sig){s.lastBufferPosition=u,s.lastBytesRead=h,s.complete();return}if(f===E)return p.emit(\"error\",new Error(\"Bad archive\"));if(s.lastPos=f+1,s.chunkSize*=2,f<=E)return p.emit(\"error\",new Error(\"Bad archive\"));let _=Math.min(s.chunkSize,f-E);s.win.expandLeft(_,y)}function S(){let n=Math.min(o.ENDHDR+o.MAXFILECOMMENT,t);s={win:new ne(e),totalReadLength:n,minPos:t-n,lastPos:t,chunkSize:Math.min(1024,i),firstByte:o.ENDSIGFIRST,sig:o.ENDSIG,complete:I},s.win.read(t-s.chunkSize,s.chunkSize,y)}function I(){let n=s.win.buffer,h=s.lastBufferPosition;try{c=new pe,c.read(n.slice(h,h+o.ENDHDR)),c.headerOffset=s.win.position+h,c.commentLength?p.comment=n.slice(h+o.ENDHDR,h+o.ENDHDR+c.commentLength).toString():p.comment=null,p.entriesCount=c.volumeEntries,p.centralDirectory=c,c.volumeEntries===o.EF_ZIP64_OR_16&&c.totalEntries===o.EF_ZIP64_OR_16||c.size===o.EF_ZIP64_OR_32||c.offset===o.EF_ZIP64_OR_32?U():(s={},H())}catch(f){p.emit(\"error\",f)}}function U(){let n=o.ENDL64HDR;s.lastBufferPosition>n?(s.lastBufferPosition-=n,k()):(s={win:s.win,totalReadLength:n,minPos:s.win.position-n,lastPos:s.win.position,chunkSize:s.chunkSize,firstByte:o.ENDL64SIGFIRST,sig:o.ENDL64SIG,complete:k},s.win.read(s.lastPos-s.chunkSize,s.chunkSize,y))}function k(){let n=s.win.buffer,h=new Ee;h.read(n.slice(s.lastBufferPosition,s.lastBufferPosition+o.ENDL64HDR));let f=t-h.headerOffset;s={win:s.win,totalReadLength:f,minPos:h.headerOffset,lastPos:s.lastPos,chunkSize:s.chunkSize,firstByte:o.END64SIGFIRST,sig:o.END64SIG,complete:fe},s.win.read(t-s.chunkSize,s.chunkSize,y)}function fe(){let n=s.win.buffer,h=new me;h.read(n.slice(s.lastBufferPosition,s.lastBufferPosition+o.END64HDR)),p.centralDirectory.volumeEntries=h.volumeEntries,p.centralDirectory.totalEntries=h.totalEntries,p.centralDirectory.size=h.size,p.centralDirectory.offset=h.offset,p.entriesCount=h.volumeEntries,s={},H()}function H(){s={win:new ne(e),pos:c.offset,chunkSize:i,entriesLeft:c.volumeEntries},s.win.read(s.pos,Math.min(i,t-s.pos),le)}function le(n,h){if(n||!h)return p.emit(\"error\",n||new Error(\"Entries read error\"));let f=s.pos-s.win.position,u=s.entry,g=s.win.buffer,E=g.length;try{for(;s.entriesLeft>0;){u||(u=new Ce,u.readHeader(g,f),u.headerOffset=s.win.position+f,s.entry=u,s.pos+=o.CENHDR,f+=o.CENHDR);let _=u.fnameLen+u.extraLen+u.comLen,v=_+(s.entriesLeft>1?o.CENHDR:0);if(E-f{if(f)return h(f);let g=ie(u),E=new ge(e,g,u.compressedSize);if(u.method!==o.STORED)if(u.method===o.DEFLATED)E=E.pipe(Ue.createInflateRaw());else return h(new Error(\"Unknown compression method: \"+u.method));J(u)&&(E=E.pipe(new we(E,u.crc,u.size))),h(null,E)},!1)},this.entryDataSync=function(n){let h=null;if(this.openEntry(n,(u,g)=>{h=u,n=g},!0),h)throw h;let f=Buffer.alloc(n.compressedSize);if(new B(e,f,0,n.compressedSize,ie(n),u=>{h=u}).read(!0),h)throw h;if(n.method!==o.STORED)if(n.method===o.DEFLATED||n.method===o.ENHANCED_DEFLATED)f=Ue.inflateRawSync(f);else throw new Error(\"Unknown compression method: \"+n.method);if(f.length!==n.size)throw new Error(\"Invalid size\");return J(n)&&new A(n.crc,n.size).data(f),f},this.openEntry=function(n,h,f){if(typeof n==\"string\"&&(Z(),n=m[n],!n))return h(new Error(\"Entry not found\"));if(!n.isFile)return h(new Error(\"Entry is not file\"));if(!e)return h(new Error(\"Archive closed\"));let u=Buffer.alloc(o.LOCHDR);new B(e,u,0,u.length,n.offset,g=>{if(g)return h(g);let E;try{n.readDataHeader(u),n.encrypted&&(E=new Error(\"Entry encrypted\"))}catch(_){E=_}h(E,n)}).read(f)};function ie(n){return n.offset+o.LOCHDR+n.fnameLen+n.extraLen}function J(n){return(n.flags&8)!==8}function Q(n,h,f){p.stream(n,(u,g)=>{if(u)f(u);else{let E,_;g.on(\"error\",v=>{_=v,E&&(g.unpipe(E),E.close(()=>{f(v)}))}),N.open(h,\"w\",(v,x)=>{if(v)return f(v);if(_){N.close(e,()=>{f(_)});return}E=N.createWriteStream(h,{fd:x}),E.on(\"finish\",()=>{p.emit(\"extract\",n,h),_||f()}),g.pipe(E)})}})}function Ne(n,h,f){if(!h.length)return f();let u=h.shift();u=W.join(n,W.join(...u)),N.mkdir(u,{recursive:!0},g=>{if(g&&g.code!==\"EEXIST\")return f(g);Ne(n,h,f)})}function de(n,h,f,u,g){if(!f.length)return u(null,g);let E=f.shift(),_=W.join(n,E.name.replace(h,\"\"));Q(E,_,v=>{if(v)return u(v,g);de(n,h,f,u,g+1)})}this.extract=function(n,h,f){let u=n||\"\";if(typeof n==\"string\"&&(n=this.entry(n),n?u=n.name:u.length&&u[u.length-1]!==\"/\"&&(u+=\"/\")),!n||n.isDirectory){let g=[],E=[],_={};for(let v in m)if(Object.prototype.hasOwnProperty.call(m,v)&&v.lastIndexOf(u,0)===0){let x=v.replace(u,\"\"),be=m[v];if(be.isFile&&(g.push(be),x=W.dirname(x)),x&&!_[x]&&x!==\".\"){_[x]=!0;let M=x.split(\"/\").filter(ee=>ee);for(M.length&&E.push(M);M.length>1;){M=M.slice(0,M.length-1);let ee=M.join(\"/\");if(_[ee]||ee===\".\")break;_[ee]=!0,E.push(M)}}}E.sort((v,x)=>v.length-x.length),E.length?Ne(h,E,v=>{v?f(v):de(h,u,g,f,0)}):de(h,u,g,f,0)}else N.stat(h,(g,E)=>{E&&E.isDirectory()?Q(n,W.join(h,W.basename(n.name)),f):Q(n,h,f)})},this.close=function(n){d||!e?(d=!0,n&&n()):(d=!0,N.close(e,h=>{e=null,n&&n(h)}))};let ut=_e.EventEmitter.prototype.emit;this.emit=function(...n){if(!d)return ut.call(this,...n)}};G.setFs=function(r){N=r};G.debugLog=(...r)=>{G.debug&&console.log(...r)};Ct.inherits(G,_e.EventEmitter);var z=Symbol(\"zip\");G.async=class extends _e.EventEmitter{constructor(e){super();let t=new G(e);t.on(\"entry\",i=>this.emit(\"entry\",i)),t.on(\"extract\",(i,s)=>this.emit(\"extract\",i,s)),this[z]=new Promise((i,s)=>{t.on(\"ready\",()=>{t.removeListener(\"error\",s),i(t)}),t.on(\"error\",s)})}get entriesCount(){return this[z].then(e=>e.entriesCount)}get comment(){return this[z].then(e=>e.comment)}async entry(e){return(await this[z]).entry(e)}async entries(){return(await this[z]).entries()}async stream(e){let t=await this[z];return new Promise((i,s)=>{t.stream(e,(c,d)=>{c?s(c):i(d)})})}async entryData(e){let t=await this.stream(e);return new Promise((i,s)=>{let c=[];t.on(\"data\",d=>c.push(d)),t.on(\"end\",()=>{i(Buffer.concat(c))}),t.on(\"error\",d=>{t.removeAllListeners(\"end\"),s(d)})})}async extract(e,t){let i=await this[z];return new Promise((s,c)=>{i.extract(e,t,(d,w)=>{d?c(d):s(w)})})}async close(){let e=await this[z];return new Promise((t,i)=>{e.close(s=>{s?i(s):t()})})}};var pe=class{read(e){if(e.length!==o.ENDHDR||e.readUInt32LE(0)!==o.ENDSIG)throw new Error(\"Invalid central directory\");this.volumeEntries=e.readUInt16LE(o.ENDSUB),this.totalEntries=e.readUInt16LE(o.ENDTOT),this.size=e.readUInt32LE(o.ENDSIZ),this.offset=e.readUInt32LE(o.ENDOFF),this.commentLength=e.readUInt16LE(o.ENDCOM)}},Ee=class{read(e){if(e.length!==o.ENDL64HDR||e.readUInt32LE(0)!==o.ENDL64SIG)throw new Error(\"Invalid zip64 central directory locator\");this.headerOffset=P(e,o.ENDSUB)}},me=class{read(e){if(e.length!==o.END64HDR||e.readUInt32LE(0)!==o.END64SIG)throw new Error(\"Invalid central directory\");this.volumeEntries=P(e,o.END64SUB),this.totalEntries=P(e,o.END64TOT),this.size=P(e,o.END64SIZ),this.offset=P(e,o.END64OFF)}},Ce=class{readHeader(e,t){if(e.length=8&&this.size===o.EF_ZIP64_OR_32&&(this.size=P(e,t),t+=8,i-=8),i>=8&&this.compressedSize===o.EF_ZIP64_OR_32&&(this.compressedSize=P(e,t),t+=8,i-=8),i>=8&&this.offset===o.EF_ZIP64_OR_32&&(this.offset=P(e,t),t+=8,i-=8),i>=4&&this.diskStart===o.EF_ZIP64_OR_16&&(this.diskStart=e.readUInt32LE(t))}get encrypted(){return(this.flags&o.FLG_ENTRY_ENC)===o.FLG_ENTRY_ENC}get isFile(){return!this.isDirectory}},B=class{constructor(e,t,i,s,c,d){this.fd=e,this.buffer=t,this.offset=i,this.length=s,this.position=c,this.callback=d,this.bytesRead=0,this.waiting=!1}read(e){G.debugLog(\"read\",this.position,this.bytesRead,this.length,this.offset),this.waiting=!0;let t;if(e){let i=0;try{i=N.readSync(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead)}catch(s){t=s}this.readCallback(e,t,t?i:null)}else N.read(this.fd,this.buffer,this.offset+this.bytesRead,this.length-this.bytesRead,this.position+this.bytesRead,this.readCallback.bind(this,e))}readCallback(e,t,i){if(typeof i==\"number\"&&(this.bytesRead+=i),t||!i||this.bytesRead===this.length)return this.waiting=!1,this.callback(t,this.bytesRead);this.read(e)}},ne=class{constructor(e){this.position=0,this.buffer=Buffer.alloc(0),this.fd=e,this.fsOp=null}checkOp(){if(this.fsOp&&this.fsOp.waiting)throw new Error(\"Operation in progress\")}read(e,t,i){this.checkOp(),this.buffer.length{this.emit(\"error\",s)})}_transform(e,t,i){let s;try{this.verify.data(e)}catch(c){s=c}i(s,e)}},A=class{constructor(e,t){this.crc=e,this.size=t,this.state={crc:-1,size:0}}data(e){let t=A.getCrcTable(),i=this.state.crc,s=0,c=e.length;for(;--c>=0;)i=t[(i^e[s++])&255]^i>>>8;if(this.state.crc=i,this.state.size+=e.length,this.state.size>=this.size){let d=Buffer.alloc(4);if(d.writeInt32LE(~this.state.crc&4294967295,0),i=d.readUInt32LE(0),i!==this.crc)throw new Error(\"Invalid CRC\");if(this.state.size!==this.size)throw new Error(\"Invalid size\")}}static getCrcTable(){let e=A.crcTable;if(!e){A.crcTable=e=[];let t=Buffer.alloc(4);for(let i=0;i<256;i++){let s=i;for(let c=8;--c>=0;)(s&1)!==0?s=3988292384^s>>>1:s=s>>>1;s<0&&(t.writeInt32LE(s,0),s=t.readUInt32LE(0)),e[i]=s}}return e}};function Me(r,e){let t=ze(r,16),i=ze(e,16),s={h:parseInt(t.slice(0,5).join(\"\"),2),m:parseInt(t.slice(5,11).join(\"\"),2),s:parseInt(t.slice(11,16).join(\"\"),2)*2,Y:parseInt(i.slice(0,7).join(\"\"),2)+1980,M:parseInt(i.slice(7,11).join(\"\"),2),D:parseInt(i.slice(11,16).join(\"\"),2)},c=[s.Y,s.M,s.D].join(\"-\")+\" \"+[s.h,s.m,s.s].join(\":\")+\" GMT+0\";return new Date(c).getTime()}function ze(r,e){let t=(r>>>0).toString(2);for(;t.length{var K=1e3,V=K*60,Y=V*60,j=Y*24,gt=j*7,wt=j*365.25;Ge.exports=function(r,e){e=e||{};var t=typeof r;if(t===\"string\"&&r.length>0)return _t(r);if(t===\"number\"&&isFinite(r))return e.long?Lt(r):vt(r);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(r))};function _t(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!!e){var t=parseFloat(e[1]),i=(e[2]||\"ms\").toLowerCase();switch(i){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return t*wt;case\"weeks\":case\"week\":case\"w\":return t*gt;case\"days\":case\"day\":case\"d\":return t*j;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return t*Y;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return t*V;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return t*K;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return t;default:return}}}}function vt(r){var e=Math.abs(r);return e>=j?Math.round(r/j)+\"d\":e>=Y?Math.round(r/Y)+\"h\":e>=V?Math.round(r/V)+\"m\":e>=K?Math.round(r/K)+\"s\":r+\"ms\"}function Lt(r){var e=Math.abs(r);return e>=j?oe(r,e,j,\"day\"):e>=Y?oe(r,e,Y,\"hour\"):e>=V?oe(r,e,V,\"minute\"):e>=K?oe(r,e,K,\"second\"):r+\" ms\"}function oe(r,e,t,i){var s=e>=t*1.5;return Math.round(r/t)+\" \"+i+(s?\"s\":\"\")}});var ve=T((Qt,ke)=>{function Rt(r){t.debug=t,t.default=t,t.coerce=p,t.disable=c,t.enable=s,t.enabled=d,t.humanize=qe(),t.destroy=m,Object.keys(r).forEach(a=>{t[a]=r[a]}),t.names=[],t.skips=[],t.formatters={};function e(a){let l=0;for(let C=0;C{if(Z===\"%%\")return\"%\";H++;let J=t.formatters[ie];if(typeof J==\"function\"){let Q=I[H];Z=J.call(U,Q),I.splice(H,1),H--}return Z}),t.formatArgs.call(U,I),(U.log||t.log).apply(U,I)}return S.namespace=a,S.useColors=t.useColors(),S.color=t.selectColor(a),S.extend=i,S.destroy=t.destroy,Object.defineProperty(S,\"enabled\",{enumerable:!0,configurable:!1,get:()=>C!==null?C:(F!==t.namespaces&&(F=t.namespaces,y=t.enabled(a)),y),set:I=>{C=I}}),typeof t.init==\"function\"&&t.init(S),S}function i(a,l){let C=t(this.namespace+(typeof l>\"u\"?\":\":l)+a);return C.log=this.log,C}function s(a){t.save(a),t.namespaces=a,t.names=[],t.skips=[];let l,C=(typeof a==\"string\"?a:\"\").split(/[\\s,]+/),F=C.length;for(l=0;l\"-\"+l)].join(\",\");return t.enable(\"\"),a}function d(a){if(a[a.length-1]===\"*\")return!0;let l,C;for(l=0,C=t.skips.length;l{D.formatArgs=yt;D.save=Dt;D.load=Ot;D.useColors=It;D.storage=Ft();D.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})();D.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"];function It(){return typeof window<\"u\"&&window.process&&(window.process.type===\"renderer\"||window.process.__nwjs)?!0:typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)?!1:typeof document<\"u\"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<\"u\"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<\"u\"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)}function yt(r){if(r[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+r[0]+(this.useColors?\"%c \":\" \")+\"+\"+ce.exports.humanize(this.diff),!this.useColors)return;let e=\"color: \"+this.color;r.splice(1,0,e,\"color: inherit\");let t=0,i=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!==\"%%\"&&(t++,s===\"%c\"&&(i=t))}),r.splice(i,0,e)}D.log=console.debug||console.log||(()=>{});function Dt(r){try{r?D.storage.setItem(\"debug\",r):D.storage.removeItem(\"debug\")}catch{}}function Ot(){let r;try{r=D.storage.getItem(\"debug\")}catch{}return!r&&typeof process<\"u\"&&\"env\"in process&&(r=process.env.DEBUG),r}function Ft(){try{return localStorage}catch{}}ce.exports=ve()(D);var{formatters:St}=ce.exports;St.j=function(r){try{return JSON.stringify(r)}catch(e){return\"[UnexpectedJSONParseError]: \"+e.message}}});var je=T((er,Ze)=>{\"use strict\";Ze.exports=(r,e=process.argv)=>{let t=r.startsWith(\"-\")?\"\":r.length===1?\"-\":\"--\",i=e.indexOf(t+r),s=e.indexOf(\"--\");return i!==-1&&(s===-1||i{\"use strict\";var Nt=require(\"os\"),Xe=require(\"tty\"),b=je(),{env:L}=process,q;b(\"no-color\")||b(\"no-colors\")||b(\"color=false\")||b(\"color=never\")?q=0:(b(\"color\")||b(\"colors\")||b(\"color=true\")||b(\"color=always\"))&&(q=1);\"FORCE_COLOR\"in L&&(L.FORCE_COLOR===\"true\"?q=1:L.FORCE_COLOR===\"false\"?q=0:q=L.FORCE_COLOR.length===0?1:Math.min(parseInt(L.FORCE_COLOR,10),3));function Le(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Re(r,e){if(q===0)return 0;if(b(\"color=16m\")||b(\"color=full\")||b(\"color=truecolor\"))return 3;if(b(\"color=256\"))return 2;if(r&&!e&&q===void 0)return 0;let t=q||0;if(L.TERM===\"dumb\")return t;if(process.platform===\"win32\"){let i=Nt.release().split(\".\");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if(\"CI\"in L)return[\"TRAVIS\",\"CIRCLECI\",\"APPVEYOR\",\"GITLAB_CI\",\"GITHUB_ACTIONS\",\"BUILDKITE\"].some(i=>i in L)||L.CI_NAME===\"codeship\"?1:t;if(\"TEAMCITY_VERSION\"in L)return/^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(L.TEAMCITY_VERSION)?1:0;if(L.COLORTERM===\"truecolor\")return 3;if(\"TERM_PROGRAM\"in L){let i=parseInt((L.TERM_PROGRAM_VERSION||\"\").split(\".\")[0],10);switch(L.TERM_PROGRAM){case\"iTerm.app\":return i>=3?3:2;case\"Apple_Terminal\":return 2}}return/-256(color)?$/i.test(L.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(L.TERM)||\"COLORTERM\"in L?1:t}function bt(r){let e=Re(r,r&&r.isTTY);return Le(e)}$e.exports={supportsColor:bt,stdout:Le(Re(!0,Xe.isatty(1))),stderr:Le(Re(!0,Xe.isatty(2)))}});var Ve=T((R,he)=>{var xt=require(\"tty\"),ae=require(\"util\");R.init=At;R.log=zt;R.formatArgs=Ut;R.save=Bt;R.load=Pt;R.useColors=Tt;R.destroy=ae.deprecate(()=>{},\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\");R.colors=[6,2,3,4,5,1];try{let r=We();r&&(r.stderr||r).level>=2&&(R.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}R.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,c)=>c.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i===\"null\"?i=null:i=Number(i),r[t]=i,r},{});function Tt(){return\"colors\"in R.inspectOpts?Boolean(R.inspectOpts.colors):xt.isatty(process.stderr.fd)}function Ut(r){let{namespace:e,useColors:t}=this;if(t){let i=this.color,s=\"\\x1B[3\"+(i<8?i:\"8;5;\"+i),c=` ${s};1m${e} \\x1B[0m`;r[0]=c+r[0].split(`\n`).join(`\n`+c),r.push(s+\"m+\"+he.exports.humanize(this.diff)+\"\\x1B[0m\")}else r[0]=Mt()+e+\" \"+r[0]}function Mt(){return R.inspectOpts.hideDate?\"\":new Date().toISOString()+\" \"}function zt(...r){return process.stderr.write(ae.format(...r)+`\n`)}function Bt(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Pt(){return process.env.DEBUG}function At(r){r.inspectOpts={};let e=Object.keys(R.inspectOpts);for(let t=0;te.trim()).join(\" \")};Ke.O=function(r){return this.inspectOpts.colors=this.useColors,ae.inspect(r,this.inspectOpts)}});var Ye=T((rr,Ie)=>{typeof process>\"u\"||process.type===\"renderer\"||process.browser===!0||process.__nwjs?Ie.exports=He():Ie.exports=Ve()});var Qe=T((sr,Je)=>{var te;Je.exports=function(){if(!te){try{te=Ye()(\"follow-redirects\")}catch{}typeof te!=\"function\"&&(te=function(){})}te.apply(null,arguments)}});var ct=T((ir,Se)=>{var X=require(\"url\"),ye=X.URL,Gt=require(\"http\"),qt=require(\"https\"),rt=require(\"stream\").Writable,st=require(\"assert\"),it=Qe(),Oe=[\"abort\",\"aborted\",\"connect\",\"error\",\"socket\",\"timeout\"],Fe=Object.create(null);Oe.forEach(function(r){Fe[r]=function(e,t,i){this._redirectable.emit(r,e,t,i)}});var kt=se(\"ERR_INVALID_URL\",\"Invalid URL\",TypeError),et=se(\"ERR_FR_REDIRECTION_FAILURE\",\"Redirected request failed\"),Ht=se(\"ERR_FR_TOO_MANY_REDIRECTS\",\"Maximum number of redirects exceeded\"),Zt=se(\"ERR_FR_MAX_BODY_LENGTH_EXCEEDED\",\"Request body larger than maxBodyLength limit\"),jt=se(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\");function O(r,e){rt.call(this),this._sanitizeOptions(r),this._options=r,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],e&&this.on(\"response\",e);var t=this;this._onNativeResponse=function(i){t._processResponse(i)},this._performRequest()}O.prototype=Object.create(rt.prototype);O.prototype.abort=function(){ot(this._currentRequest),this.emit(\"abort\")};O.prototype.write=function(r,e,t){if(this._ending)throw new jt;if(!$(r)&&!Wt(r))throw new TypeError(\"data should be a string, Buffer or Uint8Array\");if(re(e)&&(t=e,e=null),r.length===0){t&&t();return}this._requestBodyLength+r.length<=this._options.maxBodyLength?(this._requestBodyLength+=r.length,this._requestBodyBuffers.push({data:r,encoding:e}),this._currentRequest.write(r,e,t)):(this.emit(\"error\",new Zt),this.abort())};O.prototype.end=function(r,e,t){if(re(r)?(t=r,r=e=null):re(e)&&(t=e,e=null),!r)this._ended=this._ending=!0,this._currentRequest.end(null,null,t);else{var i=this,s=this._currentRequest;this.write(r,e,function(){i._ended=!0,s.end(null,null,t)}),this._ending=!0}};O.prototype.setHeader=function(r,e){this._options.headers[r]=e,this._currentRequest.setHeader(r,e)};O.prototype.removeHeader=function(r){delete this._options.headers[r],this._currentRequest.removeHeader(r)};O.prototype.setTimeout=function(r,e){var t=this;function i(d){d.setTimeout(r),d.removeListener(\"timeout\",d.destroy),d.addListener(\"timeout\",d.destroy)}function s(d){t._timeout&&clearTimeout(t._timeout),t._timeout=setTimeout(function(){t.emit(\"timeout\"),c()},r),i(d)}function c(){t._timeout&&(clearTimeout(t._timeout),t._timeout=null),t.removeListener(\"abort\",c),t.removeListener(\"error\",c),t.removeListener(\"response\",c),e&&t.removeListener(\"timeout\",e),t.socket||t._currentRequest.removeListener(\"socket\",s)}return e&&this.on(\"timeout\",e),this.socket?s(this.socket):this._currentRequest.once(\"socket\",s),this.on(\"socket\",i),this.on(\"abort\",c),this.on(\"error\",c),this.on(\"response\",c),this};[\"flushHeaders\",\"getHeader\",\"setNoDelay\",\"setSocketKeepAlive\"].forEach(function(r){O.prototype[r]=function(e,t){return this._currentRequest[r](e,t)}});[\"aborted\",\"connection\",\"socket\"].forEach(function(r){Object.defineProperty(O.prototype,r,{get:function(){return this._currentRequest[r]}})});O.prototype._sanitizeOptions=function(r){if(r.headers||(r.headers={}),r.host&&(r.hostname||(r.hostname=r.host),delete r.host),!r.pathname&&r.path){var e=r.path.indexOf(\"?\");e<0?r.pathname=r.path:(r.pathname=r.path.substring(0,e),r.search=r.path.substring(e))}};O.prototype._performRequest=function(){var r=this._options.protocol,e=this._options.nativeProtocols[r];if(!e){this.emit(\"error\",new TypeError(\"Unsupported protocol \"+r));return}if(this._options.agents){var t=r.slice(0,-1);this._options.agent=this._options.agents[t]}var i=this._currentRequest=e.request(this._options,this._onNativeResponse);i._redirectable=this;for(var s of Oe)i.on(s,Fe[s]);if(this._currentUrl=/^\\//.test(this._options.path)?X.format(this._options):this._options.path,this._isRedirect){var c=0,d=this,w=this._requestBodyBuffers;(function p(m){if(i===d._currentRequest)if(m)d.emit(\"error\",m);else if(c=400){r.responseUrl=this._currentUrl,r.redirects=this._redirects,this.emit(\"response\",r),this._requestBodyBuffers=[];return}if(ot(this._currentRequest),r.destroy(),++this._redirectCount>this._options.maxRedirects){this.emit(\"error\",new Ht);return}var i,s=this._options.beforeRedirect;s&&(i=Object.assign({Host:r.req.getHeader(\"host\")},this._options.headers));var c=this._options.method;((e===301||e===302)&&this._options.method===\"POST\"||e===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method=\"GET\",this._requestBodyBuffers=[],De(/^content-/i,this._options.headers));var d=De(/^host$/i,this._options.headers),w=X.parse(this._currentUrl),p=d||w.host,m=/^\\w+:/.test(t)?this._currentUrl:X.format(Object.assign(w,{host:p})),a;try{a=X.resolve(m,t)}catch(y){this.emit(\"error\",new et({cause:y}));return}it(\"redirecting to\",a),this._isRedirect=!0;var l=X.parse(a);if(Object.assign(this._options,l),(l.protocol!==w.protocol&&l.protocol!==\"https:\"||l.host!==p&&!$t(l.host,p))&&De(/^(?:authorization|cookie)$/i,this._options.headers),re(s)){var C={headers:r.headers,statusCode:e},F={url:m,method:c,headers:i};try{s(this._options,C,F)}catch(y){this.emit(\"error\",y);return}this._sanitizeOptions(this._options)}try{this._performRequest()}catch(y){this.emit(\"error\",new et({cause:y}))}};function nt(r){var e={maxRedirects:21,maxBodyLength:10485760},t={};return Object.keys(r).forEach(function(i){var s=i+\":\",c=t[s]=r[i],d=e[i]=Object.create(c);function w(m,a,l){if($(m)){var C;try{C=tt(new ye(m))}catch{C=X.parse(m)}if(!$(C.protocol))throw new kt({input:m});m=C}else ye&&m instanceof ye?m=tt(m):(l=a,a=m,m={protocol:s});return re(a)&&(l=a,a=null),a=Object.assign({maxRedirects:e.maxRedirects,maxBodyLength:e.maxBodyLength},m,a),a.nativeProtocols=t,!$(a.host)&&!$(a.hostname)&&(a.hostname=\"::1\"),st.equal(a.protocol,s,\"protocol mismatch\"),it(\"options\",a),new O(a,l)}function p(m,a,l){var C=d.request(m,a,l);return C.end(),C}Object.defineProperties(d,{request:{value:w,configurable:!0,enumerable:!0,writable:!0},get:{value:p,configurable:!0,enumerable:!0,writable:!0}})}),e}function Xt(){}function tt(r){var e={protocol:r.protocol,hostname:r.hostname.startsWith(\"[\")?r.hostname.slice(1,-1):r.hostname,hash:r.hash,search:r.search,pathname:r.pathname,path:r.pathname+r.search,href:r.href};return r.port!==\"\"&&(e.port=Number(r.port)),e}function De(r,e){var t;for(var i in e)r.test(i)&&(t=e[i],delete e[i]);return t===null||typeof t>\"u\"?void 0:String(t).trim()}function se(r,e,t){function i(s){Error.captureStackTrace(this,this.constructor),Object.assign(this,s||{}),this.code=r,this.message=this.cause?e+\": \"+this.cause.message:e}return i.prototype=new(t||Error),i.prototype.constructor=i,i.prototype.name=\"Error [\"+r+\"]\",i}function ot(r){for(var e of Oe)r.removeListener(e,Fe[e]);r.on(\"error\",Xt),r.abort()}function $t(r,e){st($(r)&&$(e));var t=r.length-e.length-1;return t>0&&r[t]===\".\"&&r.endsWith(e)}function $(r){return typeof r==\"string\"||r instanceof String}function re(r){return typeof r==\"function\"}function Wt(r){return typeof r==\"object\"&&\"length\"in r}Se.exports=nt({http:Gt,https:qt});Se.exports.wrap=nt});var at=Te(Ae()),ht=Te(ct()),ue=()=>Math.random().toFixed(Math.ceil(Math.random()*6)+2).slice(2);THNK.GeckosServerAdapter=class extends THNK.ServerAdapter{constructor(t,i){super();this.id=0;this.server=null;this.httpServer=null;this.channels=new Map;this.ip=t,this.port=i}async prepare(t){let i=t.getGame().getRenderer().getElectronRemote();if(!i)throw new Error(\"The game does not seem to be running on a desktop, impossible to launch geckos server!\");let s=i.require,c;if(!t.getGame().isPreview())c=s(\"@geckos.io/server\").geckos;else{let w=s(\"fs\");if(!w.existsSync(\"./geckos-server\")){console.info(\"Geckos server not found, downloading it now!\");let{https:{get:p}}=(0,ht.wrap)({https:s(\"https\")}),{pipeline:m}=s(\"stream/promises\"),a=await new Promise(C=>p(\"https://s3.arthuro555.com/geckos-server-electron.zip\",F=>C(F)));await m(a,w.createWriteStream(\"./geckos-server.zip\"));let l=new at.async({file:\"./geckos-server.zip\"});w.mkdirSync(\"./geckos-server\"),await l.extract(null,\"./geckos-server\"),await l.close()}c=s(process.cwd()+\"/geckos-server/index.js\").geckos}if(!c)throw new Error(\"Geckos not found!\");this.server=c({label:\"THNK\"}),this.server.onConnection(w=>{let p=`${ue()}-${this.id++}-${ue()}`;this.onConnection(p),this.channels.set(p,w),w.onRaw(m=>this.onMessage(p,m)),w.onDisconnect(()=>this.onDisconnection(p))}),this.httpServer=s(\"http\").createServer(),this.server.addServer(this.httpServer),this.httpServer.listen(this.port);let d=w=>{w.returnValue=\"false\",this.close(),window.removeEventListener(\"beforeunload\",d),window.close()};window.addEventListener(\"beforeunload\",d)}close(){if(this.server&&this.httpServer){this.httpServer.close(),this.httpServer.closeAllConnections&&this.httpServer.closeAllConnections();for(let t of this.channels.values())t.close();this.channels.clear(),this.httpServer=null,this.server=null}}doSendMessageTo(t,i){let s=this.channels.get(t);s&&s.raw.emit(i.buffer.slice(i.buffer.byteLength-i.byteLength))}getServerID(){return`${ue()}-server-${ue()}`}};\n/**\n * @license node-stream-zip | (c) 2020 Antelle | https://github.com/antelle/node-stream-zip/blob/master/LICENSE\n * Portions copyright https://github.com/cthackers/adm-zip | https://raw.githubusercontent.com/cthackers/adm-zip/master/LICENSE\n */\n", "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": false diff --git a/scripts/generate-extensions.js b/scripts/generate-extensions.js index d0a88a3..219b7c3 100644 --- a/scripts/generate-extensions.js +++ b/scripts/generate-extensions.js @@ -54,3 +54,22 @@ window.${thnkCode.slice(`"use strict";var `.length)}{`; JSON.stringify(geckosServerExt, null, 2) ); } + +{ + const geckosClientCode = fs + .readFileSync(distPath + "geckos-client.global.js") + .toString(); + /** @type {{eventsFunctions: { name: string, events: { type: string, inlineCode: string }[] }[]}} */ + const geckosClientExt = JSON.parse( + fs.readFileSync(extensionsPath + "THNK_GeckosClient.json").toString() + ); + + geckosClientExt.eventsFunctions[0].events[0].inlineCode = + `// Load THNK Geckos Client Adapter (https://github.com/arthuro555/THNK)\n` + + geckosClientCode; + + fs.writeFileSync( + extensionsPath + "THNK_GeckosClient.json", + JSON.stringify(geckosClientExt, null, 2) + ); +}