@kevisual/cli 0.0.75 → 0.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistant-server.js +10 -581
- package/dist/envision.js +2 -2
- package/package.json +1 -1
package/dist/assistant-server.js
CHANGED
|
@@ -14750,9 +14750,9 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
14750
14750
|
emitErrorAndClose(websocket2, err);
|
|
14751
14751
|
});
|
|
14752
14752
|
req.on("response", (res) => {
|
|
14753
|
-
const
|
|
14753
|
+
const location = res.headers.location;
|
|
14754
14754
|
const statusCode = res.statusCode;
|
|
14755
|
-
if (
|
|
14755
|
+
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
14756
14756
|
if (++websocket2._redirects > opts.maxRedirects) {
|
|
14757
14757
|
abortHandshake(websocket2, req, "Maximum redirects exceeded");
|
|
14758
14758
|
return;
|
|
@@ -14760,9 +14760,9 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
14760
14760
|
req.abort();
|
|
14761
14761
|
let addr;
|
|
14762
14762
|
try {
|
|
14763
|
-
addr = new URL3(
|
|
14763
|
+
addr = new URL3(location, address);
|
|
14764
14764
|
} catch (e) {
|
|
14765
|
-
const err = new SyntaxError(`Invalid URL: ${
|
|
14765
|
+
const err = new SyntaxError(`Invalid URL: ${location}`);
|
|
14766
14766
|
emitErrorAndClose(websocket2, err);
|
|
14767
14767
|
return;
|
|
14768
14768
|
}
|
|
@@ -39913,7 +39913,7 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
39913
39913
|
|
|
39914
39914
|
// ../node_modules/.pnpm/commander@14.0.2/node_modules/commander/lib/command.js
|
|
39915
39915
|
var require_command = __commonJS((exports) => {
|
|
39916
|
-
var
|
|
39916
|
+
var EventEmitter2 = __require("node:events").EventEmitter;
|
|
39917
39917
|
var childProcess = __require("node:child_process");
|
|
39918
39918
|
var path14 = __require("node:path");
|
|
39919
39919
|
var fs14 = __require("node:fs");
|
|
@@ -39924,7 +39924,7 @@ var require_command = __commonJS((exports) => {
|
|
|
39924
39924
|
var { Option, DualOptions } = require_option();
|
|
39925
39925
|
var { suggestSimilar } = require_suggestSimilar();
|
|
39926
39926
|
|
|
39927
|
-
class Command extends
|
|
39927
|
+
class Command extends EventEmitter2 {
|
|
39928
39928
|
constructor(name) {
|
|
39929
39929
|
super();
|
|
39930
39930
|
this.commands = [];
|
|
@@ -44739,9 +44739,9 @@ function requireWebsocket() {
|
|
|
44739
44739
|
emitErrorAndClose(websocket2, err);
|
|
44740
44740
|
});
|
|
44741
44741
|
req.on("response", (res) => {
|
|
44742
|
-
const
|
|
44742
|
+
const location = res.headers.location;
|
|
44743
44743
|
const statusCode = res.statusCode;
|
|
44744
|
-
if (
|
|
44744
|
+
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
44745
44745
|
if (++websocket2._redirects > opts.maxRedirects) {
|
|
44746
44746
|
abortHandshake(websocket2, req, "Maximum redirects exceeded");
|
|
44747
44747
|
return;
|
|
@@ -44749,9 +44749,9 @@ function requireWebsocket() {
|
|
|
44749
44749
|
req.abort();
|
|
44750
44750
|
let addr;
|
|
44751
44751
|
try {
|
|
44752
|
-
addr = new URL2(
|
|
44752
|
+
addr = new URL2(location, address);
|
|
44753
44753
|
} catch (e) {
|
|
44754
|
-
const err = new SyntaxError(`Invalid URL: ${
|
|
44754
|
+
const err = new SyntaxError(`Invalid URL: ${location}`);
|
|
44755
44755
|
emitErrorAndClose(websocket2, err);
|
|
44756
44756
|
return;
|
|
44757
44757
|
}
|
|
@@ -75027,577 +75027,6 @@ app.route({
|
|
|
75027
75027
|
ctx.body = res.data;
|
|
75028
75028
|
}).addTo(app);
|
|
75029
75029
|
|
|
75030
|
-
// src/routes/hot-api/key-sender/index.ts
|
|
75031
|
-
import { Hotkeys } from "@kevisual/hot-api";
|
|
75032
|
-
|
|
75033
|
-
// ../node_modules/.pnpm/@kevisual+context@0.0.4/node_modules/@kevisual/context/dist/app.js
|
|
75034
|
-
var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
75035
|
-
function getDefaultExportFromCjs4(x) {
|
|
75036
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
75037
|
-
}
|
|
75038
|
-
var eventemitter32 = { exports: {} };
|
|
75039
|
-
var hasRequiredEventemitter32;
|
|
75040
|
-
function requireEventemitter32() {
|
|
75041
|
-
if (hasRequiredEventemitter32)
|
|
75042
|
-
return eventemitter32.exports;
|
|
75043
|
-
hasRequiredEventemitter32 = 1;
|
|
75044
|
-
(function(module) {
|
|
75045
|
-
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
75046
|
-
function Events() {}
|
|
75047
|
-
if (Object.create) {
|
|
75048
|
-
Events.prototype = Object.create(null);
|
|
75049
|
-
if (!new Events().__proto__)
|
|
75050
|
-
prefix = false;
|
|
75051
|
-
}
|
|
75052
|
-
function EE(fn, context, once) {
|
|
75053
|
-
this.fn = fn;
|
|
75054
|
-
this.context = context;
|
|
75055
|
-
this.once = once || false;
|
|
75056
|
-
}
|
|
75057
|
-
function addListener(emitter, event, fn, context, once) {
|
|
75058
|
-
if (typeof fn !== "function") {
|
|
75059
|
-
throw new TypeError("The listener must be a function");
|
|
75060
|
-
}
|
|
75061
|
-
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
|
75062
|
-
if (!emitter._events[evt])
|
|
75063
|
-
emitter._events[evt] = listener, emitter._eventsCount++;
|
|
75064
|
-
else if (!emitter._events[evt].fn)
|
|
75065
|
-
emitter._events[evt].push(listener);
|
|
75066
|
-
else
|
|
75067
|
-
emitter._events[evt] = [emitter._events[evt], listener];
|
|
75068
|
-
return emitter;
|
|
75069
|
-
}
|
|
75070
|
-
function clearEvent(emitter, evt) {
|
|
75071
|
-
if (--emitter._eventsCount === 0)
|
|
75072
|
-
emitter._events = new Events;
|
|
75073
|
-
else
|
|
75074
|
-
delete emitter._events[evt];
|
|
75075
|
-
}
|
|
75076
|
-
function EventEmitter2() {
|
|
75077
|
-
this._events = new Events;
|
|
75078
|
-
this._eventsCount = 0;
|
|
75079
|
-
}
|
|
75080
|
-
EventEmitter2.prototype.eventNames = function eventNames() {
|
|
75081
|
-
var names2 = [], events, name;
|
|
75082
|
-
if (this._eventsCount === 0)
|
|
75083
|
-
return names2;
|
|
75084
|
-
for (name in events = this._events) {
|
|
75085
|
-
if (has.call(events, name))
|
|
75086
|
-
names2.push(prefix ? name.slice(1) : name);
|
|
75087
|
-
}
|
|
75088
|
-
if (Object.getOwnPropertySymbols) {
|
|
75089
|
-
return names2.concat(Object.getOwnPropertySymbols(events));
|
|
75090
|
-
}
|
|
75091
|
-
return names2;
|
|
75092
|
-
};
|
|
75093
|
-
EventEmitter2.prototype.listeners = function listeners(event) {
|
|
75094
|
-
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
75095
|
-
if (!handlers)
|
|
75096
|
-
return [];
|
|
75097
|
-
if (handlers.fn)
|
|
75098
|
-
return [handlers.fn];
|
|
75099
|
-
for (var i = 0, l = handlers.length, ee = new Array(l);i < l; i++) {
|
|
75100
|
-
ee[i] = handlers[i].fn;
|
|
75101
|
-
}
|
|
75102
|
-
return ee;
|
|
75103
|
-
};
|
|
75104
|
-
EventEmitter2.prototype.listenerCount = function listenerCount(event) {
|
|
75105
|
-
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
75106
|
-
if (!listeners)
|
|
75107
|
-
return 0;
|
|
75108
|
-
if (listeners.fn)
|
|
75109
|
-
return 1;
|
|
75110
|
-
return listeners.length;
|
|
75111
|
-
};
|
|
75112
|
-
EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
75113
|
-
var evt = prefix ? prefix + event : event;
|
|
75114
|
-
if (!this._events[evt])
|
|
75115
|
-
return false;
|
|
75116
|
-
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
75117
|
-
if (listeners.fn) {
|
|
75118
|
-
if (listeners.once)
|
|
75119
|
-
this.removeListener(event, listeners.fn, undefined, true);
|
|
75120
|
-
switch (len) {
|
|
75121
|
-
case 1:
|
|
75122
|
-
return listeners.fn.call(listeners.context), true;
|
|
75123
|
-
case 2:
|
|
75124
|
-
return listeners.fn.call(listeners.context, a1), true;
|
|
75125
|
-
case 3:
|
|
75126
|
-
return listeners.fn.call(listeners.context, a1, a2), true;
|
|
75127
|
-
case 4:
|
|
75128
|
-
return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
75129
|
-
case 5:
|
|
75130
|
-
return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
75131
|
-
case 6:
|
|
75132
|
-
return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
75133
|
-
}
|
|
75134
|
-
for (i = 1, args = new Array(len - 1);i < len; i++) {
|
|
75135
|
-
args[i - 1] = arguments[i];
|
|
75136
|
-
}
|
|
75137
|
-
listeners.fn.apply(listeners.context, args);
|
|
75138
|
-
} else {
|
|
75139
|
-
var length = listeners.length, j;
|
|
75140
|
-
for (i = 0;i < length; i++) {
|
|
75141
|
-
if (listeners[i].once)
|
|
75142
|
-
this.removeListener(event, listeners[i].fn, undefined, true);
|
|
75143
|
-
switch (len) {
|
|
75144
|
-
case 1:
|
|
75145
|
-
listeners[i].fn.call(listeners[i].context);
|
|
75146
|
-
break;
|
|
75147
|
-
case 2:
|
|
75148
|
-
listeners[i].fn.call(listeners[i].context, a1);
|
|
75149
|
-
break;
|
|
75150
|
-
case 3:
|
|
75151
|
-
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
75152
|
-
break;
|
|
75153
|
-
case 4:
|
|
75154
|
-
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
75155
|
-
break;
|
|
75156
|
-
default:
|
|
75157
|
-
if (!args)
|
|
75158
|
-
for (j = 1, args = new Array(len - 1);j < len; j++) {
|
|
75159
|
-
args[j - 1] = arguments[j];
|
|
75160
|
-
}
|
|
75161
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
75162
|
-
}
|
|
75163
|
-
}
|
|
75164
|
-
}
|
|
75165
|
-
return true;
|
|
75166
|
-
};
|
|
75167
|
-
EventEmitter2.prototype.on = function on(event, fn, context) {
|
|
75168
|
-
return addListener(this, event, fn, context, false);
|
|
75169
|
-
};
|
|
75170
|
-
EventEmitter2.prototype.once = function once(event, fn, context) {
|
|
75171
|
-
return addListener(this, event, fn, context, true);
|
|
75172
|
-
};
|
|
75173
|
-
EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
75174
|
-
var evt = prefix ? prefix + event : event;
|
|
75175
|
-
if (!this._events[evt])
|
|
75176
|
-
return this;
|
|
75177
|
-
if (!fn) {
|
|
75178
|
-
clearEvent(this, evt);
|
|
75179
|
-
return this;
|
|
75180
|
-
}
|
|
75181
|
-
var listeners = this._events[evt];
|
|
75182
|
-
if (listeners.fn) {
|
|
75183
|
-
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
|
|
75184
|
-
clearEvent(this, evt);
|
|
75185
|
-
}
|
|
75186
|
-
} else {
|
|
75187
|
-
for (var i = 0, events = [], length = listeners.length;i < length; i++) {
|
|
75188
|
-
if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
|
|
75189
|
-
events.push(listeners[i]);
|
|
75190
|
-
}
|
|
75191
|
-
}
|
|
75192
|
-
if (events.length)
|
|
75193
|
-
this._events[evt] = events.length === 1 ? events[0] : events;
|
|
75194
|
-
else
|
|
75195
|
-
clearEvent(this, evt);
|
|
75196
|
-
}
|
|
75197
|
-
return this;
|
|
75198
|
-
};
|
|
75199
|
-
EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
75200
|
-
var evt;
|
|
75201
|
-
if (event) {
|
|
75202
|
-
evt = prefix ? prefix + event : event;
|
|
75203
|
-
if (this._events[evt])
|
|
75204
|
-
clearEvent(this, evt);
|
|
75205
|
-
} else {
|
|
75206
|
-
this._events = new Events;
|
|
75207
|
-
this._eventsCount = 0;
|
|
75208
|
-
}
|
|
75209
|
-
return this;
|
|
75210
|
-
};
|
|
75211
|
-
EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
|
|
75212
|
-
EventEmitter2.prototype.addListener = EventEmitter2.prototype.on;
|
|
75213
|
-
EventEmitter2.prefixed = prefix;
|
|
75214
|
-
EventEmitter2.EventEmitter = EventEmitter2;
|
|
75215
|
-
{
|
|
75216
|
-
module.exports = EventEmitter2;
|
|
75217
|
-
}
|
|
75218
|
-
})(eventemitter32);
|
|
75219
|
-
return eventemitter32.exports;
|
|
75220
|
-
}
|
|
75221
|
-
var eventemitter3Exports2 = requireEventemitter32();
|
|
75222
|
-
var EventEmitter2 = /* @__PURE__ */ getDefaultExportFromCjs4(eventemitter3Exports2);
|
|
75223
|
-
var reRunFn2 = (promiseOpts) => {
|
|
75224
|
-
const timeout = promiseOpts.timeout || 5 * 60 * 1000;
|
|
75225
|
-
const interval = promiseOpts.interval || 1000;
|
|
75226
|
-
const checkSuccess = promiseOpts?.checkSuccess || (() => true);
|
|
75227
|
-
const signal = promiseOpts.signal;
|
|
75228
|
-
return new Promise(async (resolve, reject) => {
|
|
75229
|
-
let intervalId;
|
|
75230
|
-
let timeoutId = setTimeout(() => {
|
|
75231
|
-
clearTimeout(intervalId);
|
|
75232
|
-
resolve({
|
|
75233
|
-
code: 500,
|
|
75234
|
-
message: "timeout"
|
|
75235
|
-
});
|
|
75236
|
-
}, timeout);
|
|
75237
|
-
const fn = promiseOpts.fn || (() => true);
|
|
75238
|
-
const runFn = async () => {
|
|
75239
|
-
if (signal?.aborted) {
|
|
75240
|
-
clearInterval(intervalId);
|
|
75241
|
-
clearTimeout(timeoutId);
|
|
75242
|
-
return resolve({
|
|
75243
|
-
code: 499,
|
|
75244
|
-
message: "operation cancelled"
|
|
75245
|
-
});
|
|
75246
|
-
}
|
|
75247
|
-
const res = await fn();
|
|
75248
|
-
if (!!checkSuccess(res)) {
|
|
75249
|
-
clearInterval(intervalId);
|
|
75250
|
-
clearTimeout(timeoutId);
|
|
75251
|
-
resolve({
|
|
75252
|
-
code: 200,
|
|
75253
|
-
data: res
|
|
75254
|
-
});
|
|
75255
|
-
} else {
|
|
75256
|
-
setTimeout(() => {
|
|
75257
|
-
runFn();
|
|
75258
|
-
}, interval);
|
|
75259
|
-
}
|
|
75260
|
-
};
|
|
75261
|
-
if (signal) {
|
|
75262
|
-
signal.addEventListener("abort", () => {
|
|
75263
|
-
clearInterval(intervalId);
|
|
75264
|
-
clearTimeout(timeoutId);
|
|
75265
|
-
resolve({
|
|
75266
|
-
code: 499,
|
|
75267
|
-
message: "operation cancelled"
|
|
75268
|
-
});
|
|
75269
|
-
});
|
|
75270
|
-
}
|
|
75271
|
-
runFn();
|
|
75272
|
-
});
|
|
75273
|
-
};
|
|
75274
|
-
|
|
75275
|
-
class BaseLoad2 {
|
|
75276
|
-
modules = new Map;
|
|
75277
|
-
event;
|
|
75278
|
-
loading;
|
|
75279
|
-
static reRunFn = reRunFn2;
|
|
75280
|
-
timeout = 5 * 60 * 1000;
|
|
75281
|
-
constructor() {
|
|
75282
|
-
this.event = new EventEmitter2;
|
|
75283
|
-
this.loading = false;
|
|
75284
|
-
}
|
|
75285
|
-
listenKey(key, listenOpts) {
|
|
75286
|
-
const timeout = listenOpts?.timeout ?? this.timeout;
|
|
75287
|
-
return new Promise((resolve) => {
|
|
75288
|
-
const timeoutId = setTimeout(() => {
|
|
75289
|
-
this.event.removeListener(key, onEvent);
|
|
75290
|
-
resolve({
|
|
75291
|
-
code: 500,
|
|
75292
|
-
message: "timeout"
|
|
75293
|
-
});
|
|
75294
|
-
}, timeout);
|
|
75295
|
-
const onEvent = (error2) => {
|
|
75296
|
-
clearTimeout(timeoutId);
|
|
75297
|
-
if (error2) {
|
|
75298
|
-
return resolve({
|
|
75299
|
-
code: 500,
|
|
75300
|
-
message: error2
|
|
75301
|
-
});
|
|
75302
|
-
}
|
|
75303
|
-
const data = this.modules.get(key);
|
|
75304
|
-
if (data?.loadSuccessClear) {
|
|
75305
|
-
this.remove(key);
|
|
75306
|
-
}
|
|
75307
|
-
resolve({
|
|
75308
|
-
code: 200,
|
|
75309
|
-
data: data?.modules
|
|
75310
|
-
});
|
|
75311
|
-
};
|
|
75312
|
-
this.event.once(key, onEvent);
|
|
75313
|
-
});
|
|
75314
|
-
}
|
|
75315
|
-
async hasLoaded(key, hasLoadOpts) {
|
|
75316
|
-
if (!key) {
|
|
75317
|
-
return {
|
|
75318
|
-
code: 404,
|
|
75319
|
-
message: "key is required"
|
|
75320
|
-
};
|
|
75321
|
-
}
|
|
75322
|
-
const has = this.modules.has(key);
|
|
75323
|
-
if (!has) {
|
|
75324
|
-
const isExist = hasLoadOpts?.isExist ?? true;
|
|
75325
|
-
const timeout = hasLoadOpts?.timeout ?? this.timeout;
|
|
75326
|
-
if (isExist) {
|
|
75327
|
-
return await this.listenKey(key, { timeout });
|
|
75328
|
-
}
|
|
75329
|
-
return {
|
|
75330
|
-
code: 404
|
|
75331
|
-
};
|
|
75332
|
-
}
|
|
75333
|
-
const data = this.modules.get(key);
|
|
75334
|
-
if (data?.status === "loaded") {
|
|
75335
|
-
return {
|
|
75336
|
-
code: 200,
|
|
75337
|
-
data: data.modules
|
|
75338
|
-
};
|
|
75339
|
-
}
|
|
75340
|
-
if (data?.status === "loading") {
|
|
75341
|
-
return await this.listenKey(key, { timeout: hasLoadOpts?.timeout ?? this.timeout });
|
|
75342
|
-
}
|
|
75343
|
-
if (data?.status === "error") {
|
|
75344
|
-
return {
|
|
75345
|
-
code: 500,
|
|
75346
|
-
message: "load error"
|
|
75347
|
-
};
|
|
75348
|
-
}
|
|
75349
|
-
if (data?.status === "cancel") {
|
|
75350
|
-
return {
|
|
75351
|
-
code: 499,
|
|
75352
|
-
message: "operation cancelled"
|
|
75353
|
-
};
|
|
75354
|
-
}
|
|
75355
|
-
return {
|
|
75356
|
-
code: 404
|
|
75357
|
-
};
|
|
75358
|
-
}
|
|
75359
|
-
async loadFn(loadContent, opts) {
|
|
75360
|
-
const key = opts.key;
|
|
75361
|
-
if (!key) {
|
|
75362
|
-
return {
|
|
75363
|
-
code: 404,
|
|
75364
|
-
message: "key is required"
|
|
75365
|
-
};
|
|
75366
|
-
}
|
|
75367
|
-
const newModule = {
|
|
75368
|
-
key: opts.key,
|
|
75369
|
-
status: "loading",
|
|
75370
|
-
loading: true,
|
|
75371
|
-
loadSuccessClear: opts.loadSuccessClear ?? true
|
|
75372
|
-
};
|
|
75373
|
-
let errorMessage = "";
|
|
75374
|
-
try {
|
|
75375
|
-
const isReRun = opts.isReRun ?? false;
|
|
75376
|
-
let res;
|
|
75377
|
-
if (!isReRun) {
|
|
75378
|
-
this.modules.set(key, newModule);
|
|
75379
|
-
res = await loadContent();
|
|
75380
|
-
} else {
|
|
75381
|
-
newModule.controller = new AbortController;
|
|
75382
|
-
const signal = newModule.controller.signal;
|
|
75383
|
-
this.modules.set(key, newModule);
|
|
75384
|
-
const data = await reRunFn2({
|
|
75385
|
-
timeout: opts.timeout,
|
|
75386
|
-
interval: opts.interval,
|
|
75387
|
-
checkSuccess: opts.checkSuccess,
|
|
75388
|
-
fn: loadContent,
|
|
75389
|
-
signal
|
|
75390
|
-
});
|
|
75391
|
-
newModule.controller = null;
|
|
75392
|
-
if (data.code === 499) {
|
|
75393
|
-
newModule.status = "cancel";
|
|
75394
|
-
return {
|
|
75395
|
-
code: 499,
|
|
75396
|
-
message: "operation cancelled"
|
|
75397
|
-
};
|
|
75398
|
-
}
|
|
75399
|
-
if (data.code !== 200) {
|
|
75400
|
-
throw new Error(data.message);
|
|
75401
|
-
}
|
|
75402
|
-
res = data.data;
|
|
75403
|
-
}
|
|
75404
|
-
newModule.modules = res;
|
|
75405
|
-
newModule.status = "loaded";
|
|
75406
|
-
return {
|
|
75407
|
-
code: 200,
|
|
75408
|
-
data: res
|
|
75409
|
-
};
|
|
75410
|
-
} catch (error2) {
|
|
75411
|
-
errorMessage = error2.message;
|
|
75412
|
-
newModule.status = "error";
|
|
75413
|
-
return {
|
|
75414
|
-
code: 500,
|
|
75415
|
-
message: error2
|
|
75416
|
-
};
|
|
75417
|
-
} finally {
|
|
75418
|
-
newModule.loading = false;
|
|
75419
|
-
this.modules.set(opts.key, newModule);
|
|
75420
|
-
if (!errorMessage) {
|
|
75421
|
-
this.event.emit(opts.key);
|
|
75422
|
-
} else {
|
|
75423
|
-
this.event.emit(opts.key, errorMessage);
|
|
75424
|
-
}
|
|
75425
|
-
}
|
|
75426
|
-
}
|
|
75427
|
-
async load(loadContent, opts) {
|
|
75428
|
-
this.loading = true;
|
|
75429
|
-
const key = opts.key;
|
|
75430
|
-
if (!key) {
|
|
75431
|
-
return {
|
|
75432
|
-
code: 404,
|
|
75433
|
-
message: "key is required"
|
|
75434
|
-
};
|
|
75435
|
-
}
|
|
75436
|
-
if (opts?.force) {
|
|
75437
|
-
this.remove(key);
|
|
75438
|
-
}
|
|
75439
|
-
const has = this.modules.has(key);
|
|
75440
|
-
if (has) {
|
|
75441
|
-
return await this.hasLoaded(key);
|
|
75442
|
-
}
|
|
75443
|
-
if (typeof loadContent === "function") {
|
|
75444
|
-
return this.loadFn(loadContent, opts);
|
|
75445
|
-
}
|
|
75446
|
-
console.error("loadContent is not a function and not has loaded");
|
|
75447
|
-
}
|
|
75448
|
-
remove(key) {
|
|
75449
|
-
const has = this.modules.has(key);
|
|
75450
|
-
if (has) {
|
|
75451
|
-
this.checkRemoveController(key);
|
|
75452
|
-
this.modules.delete(key);
|
|
75453
|
-
}
|
|
75454
|
-
}
|
|
75455
|
-
emitLoaded(key) {
|
|
75456
|
-
this.checkRemoveController(key);
|
|
75457
|
-
this.event.emit(key);
|
|
75458
|
-
}
|
|
75459
|
-
setModule(key, data, loadData) {
|
|
75460
|
-
const newModule = {
|
|
75461
|
-
key,
|
|
75462
|
-
status: "loaded",
|
|
75463
|
-
loading: false,
|
|
75464
|
-
modules: data || {},
|
|
75465
|
-
...loadData
|
|
75466
|
-
};
|
|
75467
|
-
this.modules.set(key, newModule);
|
|
75468
|
-
this.emitLoaded(key);
|
|
75469
|
-
return newModule;
|
|
75470
|
-
}
|
|
75471
|
-
cancel(key) {
|
|
75472
|
-
this.checkRemoveController(key);
|
|
75473
|
-
}
|
|
75474
|
-
checkRemoveController(key) {
|
|
75475
|
-
const data = this.modules.get(key);
|
|
75476
|
-
if (data?.controller) {
|
|
75477
|
-
data.controller?.abort?.();
|
|
75478
|
-
delete data.controller;
|
|
75479
|
-
this.modules.set(key, data);
|
|
75480
|
-
}
|
|
75481
|
-
}
|
|
75482
|
-
}
|
|
75483
|
-
var gt2 = globalThis || window || self;
|
|
75484
|
-
var useEnv2 = (initEnv, initKey = "config", isOverwrite) => {
|
|
75485
|
-
const env3 = gt2[initKey];
|
|
75486
|
-
const _env = env3 || initEnv;
|
|
75487
|
-
if (!env3) {
|
|
75488
|
-
if (_env) {
|
|
75489
|
-
gt2[initKey] = _env;
|
|
75490
|
-
} else {
|
|
75491
|
-
gt2[initKey] = {};
|
|
75492
|
-
}
|
|
75493
|
-
} else if (isOverwrite) {
|
|
75494
|
-
gt2[initKey] = { ...env3, ...initEnv };
|
|
75495
|
-
}
|
|
75496
|
-
return gt2[initKey];
|
|
75497
|
-
};
|
|
75498
|
-
var useEnvKey2 = (key, init, initKey = "config") => {
|
|
75499
|
-
const _env = useEnv2({}, initKey);
|
|
75500
|
-
if (key && typeof _env[key] !== "undefined") {
|
|
75501
|
-
return _env[key];
|
|
75502
|
-
}
|
|
75503
|
-
if (key && init) {
|
|
75504
|
-
if (typeof init !== "function") {
|
|
75505
|
-
_env[key] = init;
|
|
75506
|
-
}
|
|
75507
|
-
if (typeof init === "function") {
|
|
75508
|
-
const result = init();
|
|
75509
|
-
if (result instanceof Promise) {
|
|
75510
|
-
return result.then((res) => {
|
|
75511
|
-
_env[key] = res;
|
|
75512
|
-
return res;
|
|
75513
|
-
});
|
|
75514
|
-
}
|
|
75515
|
-
_env[key] = result;
|
|
75516
|
-
}
|
|
75517
|
-
return _env[key];
|
|
75518
|
-
}
|
|
75519
|
-
if (key) {
|
|
75520
|
-
const baseLoad = new BaseLoad2;
|
|
75521
|
-
const voidFn = async () => {
|
|
75522
|
-
return _env[key];
|
|
75523
|
-
};
|
|
75524
|
-
const checkFn = async () => {
|
|
75525
|
-
const loadRes = await baseLoad.load(voidFn, {
|
|
75526
|
-
key,
|
|
75527
|
-
isReRun: true,
|
|
75528
|
-
checkSuccess: () => _env[key],
|
|
75529
|
-
timeout: 5 * 60 * 1000,
|
|
75530
|
-
interval: 1000
|
|
75531
|
-
});
|
|
75532
|
-
if (loadRes.code !== 200) {
|
|
75533
|
-
console.error("load key error");
|
|
75534
|
-
return null;
|
|
75535
|
-
}
|
|
75536
|
-
return _env[key];
|
|
75537
|
-
};
|
|
75538
|
-
return checkFn();
|
|
75539
|
-
}
|
|
75540
|
-
console.error("key is empty ");
|
|
75541
|
-
return null;
|
|
75542
|
-
};
|
|
75543
|
-
var useEnvKeyNew2 = (key, initKey = "config", opts) => {
|
|
75544
|
-
const _env = useEnv2({}, initKey);
|
|
75545
|
-
if (key) {
|
|
75546
|
-
delete _env[key];
|
|
75547
|
-
}
|
|
75548
|
-
if (opts?.getNew && opts.init) {
|
|
75549
|
-
return useEnvKey2(key, opts.init, initKey);
|
|
75550
|
-
} else if (opts?.getNew) {
|
|
75551
|
-
return useEnvKey2(key, null, initKey);
|
|
75552
|
-
}
|
|
75553
|
-
};
|
|
75554
|
-
var useContextKey2 = (key, init, isNew) => {
|
|
75555
|
-
if (isNew) {
|
|
75556
|
-
return useEnvKeyNew2(key, "context", { getNew: true, init });
|
|
75557
|
-
}
|
|
75558
|
-
return useEnvKey2(key, init, "context");
|
|
75559
|
-
};
|
|
75560
|
-
var use2 = useContextKey2;
|
|
75561
|
-
var useConfigKey2 = (key, init, isNew) => {
|
|
75562
|
-
if (isNew) {
|
|
75563
|
-
return useEnvKeyNew2(key, "config", { getNew: true, init });
|
|
75564
|
-
}
|
|
75565
|
-
return useEnvKey2(key, init, "config");
|
|
75566
|
-
};
|
|
75567
|
-
class InitEnv2 {
|
|
75568
|
-
static isInit = false;
|
|
75569
|
-
static init(opts) {
|
|
75570
|
-
if (InitEnv2.isInit) {
|
|
75571
|
-
return;
|
|
75572
|
-
}
|
|
75573
|
-
const { load: load2 = true, page = false } = opts || {};
|
|
75574
|
-
InitEnv2.isInit = true;
|
|
75575
|
-
gt2.useConfigKey = useConfigKey2;
|
|
75576
|
-
gt2.useContextKey = useContextKey2;
|
|
75577
|
-
gt2.use = use2;
|
|
75578
|
-
gt2.webEnv = { useConfigKey: useConfigKey2, useContextKey: useContextKey2, use: use2 };
|
|
75579
|
-
load2 && (gt2.Load = BaseLoad2);
|
|
75580
|
-
}
|
|
75581
|
-
}
|
|
75582
|
-
InitEnv2.init();
|
|
75583
|
-
|
|
75584
|
-
// src/routes/hot-api/key-sender/index.ts
|
|
75585
|
-
app.route({
|
|
75586
|
-
path: "key-sender"
|
|
75587
|
-
}).define(async (ctx) => {
|
|
75588
|
-
let keys = ctx.query.keys;
|
|
75589
|
-
if (keys.includes(" ")) {
|
|
75590
|
-
keys = keys.replace(/\s+/g, "+");
|
|
75591
|
-
}
|
|
75592
|
-
const hotKeys = useContextKey2("hotkeys", () => new Hotkeys);
|
|
75593
|
-
if (typeof keys === "string") {
|
|
75594
|
-
await hotKeys.pressHotkey({
|
|
75595
|
-
hotkey: keys
|
|
75596
|
-
});
|
|
75597
|
-
}
|
|
75598
|
-
ctx.body = "ok";
|
|
75599
|
-
}).addTo(app);
|
|
75600
|
-
|
|
75601
75030
|
// src/routes/index.ts
|
|
75602
75031
|
import os4 from "node:os";
|
|
75603
75032
|
|
package/dist/envision.js
CHANGED
|
@@ -40664,8 +40664,8 @@ InitEnv.init();
|
|
|
40664
40664
|
var version = useContextKey("version", () => {
|
|
40665
40665
|
let version2 = "0.0.64";
|
|
40666
40666
|
try {
|
|
40667
|
-
if ("0.0.
|
|
40668
|
-
version2 = "0.0.
|
|
40667
|
+
if ("0.0.76")
|
|
40668
|
+
version2 = "0.0.76";
|
|
40669
40669
|
} catch (e) {}
|
|
40670
40670
|
return version2;
|
|
40671
40671
|
});
|