@kevisual/api 0.0.60 → 0.0.62
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/query-ai.js +3 -3
- package/dist/query-app.js +3 -3
- package/dist/query-config.js +1 -1
- package/dist/query-login-node.d.ts +5 -2
- package/dist/query-login-node.js +233 -15
- package/dist/query-login.d.ts +5 -2
- package/dist/query-login.js +238 -19
- package/dist/query-mark.js +1 -1
- package/dist/query-proxy.d.ts +20 -0
- package/dist/query-proxy.js +252 -24
- package/dist/query-resources.js +1 -1
- package/dist/query-secret.js +1 -1
- package/dist/query-shop.js +3 -3
- package/dist/store-mark.js +1 -1
- package/package.json +7 -7
- package/query/query-login/browser-cache/cache-store.ts +123 -0
- package/query/query-login/browser-cache/cache.ts +29 -0
- package/query/query-login/login-cache.ts +13 -11
- package/query/query-login/query-login-browser.ts +1 -1
- package/query/query-login/query-login.ts +23 -5
- package/query/query-proxy/proxy.ts +23 -5
- package/query/query-proxy/router-api-proxy.ts +4 -0
package/dist/query-proxy.js
CHANGED
|
@@ -194,7 +194,7 @@ var require_eventemitter32 = __commonJS((exports, module) => {
|
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
-
// node_modules/@kevisual/query/dist/query-browser.js
|
|
197
|
+
// node_modules/.pnpm/@kevisual+query@0.0.52/node_modules/@kevisual/query/dist/query-browser.js
|
|
198
198
|
var isTextForContentType = (contentType) => {
|
|
199
199
|
if (!contentType)
|
|
200
200
|
return false;
|
|
@@ -685,7 +685,7 @@ class QueryClient extends Query {
|
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
-
// node_modules/@kevisual/router/dist/router-browser.js
|
|
688
|
+
// node_modules/.pnpm/@kevisual+router@0.0.85/node_modules/@kevisual/router/dist/router-browser.js
|
|
689
689
|
var __create2 = Object.create;
|
|
690
690
|
var __getProtoOf2 = Object.getPrototypeOf;
|
|
691
691
|
var __defProp2 = Object.defineProperty;
|
|
@@ -14655,7 +14655,7 @@ class Route {
|
|
|
14655
14655
|
if (opts) {
|
|
14656
14656
|
this.id = opts.id || randomId(12, "rand-");
|
|
14657
14657
|
if (!opts.id && opts.idUsePath) {
|
|
14658
|
-
const delimiter = opts.delimiter ?? "
|
|
14658
|
+
const delimiter = opts.delimiter ?? "$$";
|
|
14659
14659
|
this.id = path + delimiter + key;
|
|
14660
14660
|
}
|
|
14661
14661
|
this.run = opts.run;
|
|
@@ -14778,6 +14778,7 @@ class QueryRouter {
|
|
|
14778
14778
|
const maxNextRoute = this.maxNextRoute;
|
|
14779
14779
|
ctx = ctx || {};
|
|
14780
14780
|
ctx.currentPath = path;
|
|
14781
|
+
ctx.currentId = route?.id;
|
|
14781
14782
|
ctx.currentKey = key;
|
|
14782
14783
|
ctx.currentRoute = route;
|
|
14783
14784
|
ctx.index = (ctx.index || 0) + 1;
|
|
@@ -14791,7 +14792,7 @@ class QueryRouter {
|
|
|
14791
14792
|
ctx.code = 500;
|
|
14792
14793
|
ctx.message = "Too many nextRoute";
|
|
14793
14794
|
ctx.body = null;
|
|
14794
|
-
return;
|
|
14795
|
+
return ctx;
|
|
14795
14796
|
}
|
|
14796
14797
|
if (route && route.middleware && route.middleware.length > 0) {
|
|
14797
14798
|
const errorMiddleware = [];
|
|
@@ -14866,7 +14867,9 @@ class QueryRouter {
|
|
|
14866
14867
|
}
|
|
14867
14868
|
return ctx;
|
|
14868
14869
|
}
|
|
14869
|
-
if (ctx.end) {
|
|
14870
|
+
if (ctx.end) {
|
|
14871
|
+
return ctx;
|
|
14872
|
+
}
|
|
14870
14873
|
}
|
|
14871
14874
|
}
|
|
14872
14875
|
}
|
|
@@ -15060,7 +15063,7 @@ class QueryRouter {
|
|
|
15060
15063
|
description: "列出当前应用下的所有的路由信息",
|
|
15061
15064
|
middleware: opts?.middleware || [],
|
|
15062
15065
|
run: async (ctx) => {
|
|
15063
|
-
const tokenUser = ctx.state
|
|
15066
|
+
const tokenUser = ctx.state;
|
|
15064
15067
|
let isUser = !!tokenUser;
|
|
15065
15068
|
const list = this.getList(opts?.filter).filter((item) => {
|
|
15066
15069
|
if (item.id === "auth" || item.id === "auth-can" || item.id === "check-auth-admin" || item.id === "auth-admin") {
|
|
@@ -15095,7 +15098,10 @@ class QueryRouterServer extends QueryRouter {
|
|
|
15095
15098
|
handle;
|
|
15096
15099
|
constructor(opts) {
|
|
15097
15100
|
super();
|
|
15098
|
-
|
|
15101
|
+
const initHandle = opts?.initHandle ?? true;
|
|
15102
|
+
if (initHandle || opts?.handleFn) {
|
|
15103
|
+
this.handle = this.getHandle(this, opts?.handleFn, opts?.context);
|
|
15104
|
+
}
|
|
15099
15105
|
this.setContext({ needSerialize: false, ...opts?.context });
|
|
15100
15106
|
if (opts?.appId) {
|
|
15101
15107
|
this.appId = opts.appId;
|
|
@@ -15126,15 +15132,8 @@ class QueryRouterServer extends QueryRouter {
|
|
|
15126
15132
|
}
|
|
15127
15133
|
return new Route(path, key, opts);
|
|
15128
15134
|
}
|
|
15129
|
-
prompt(
|
|
15130
|
-
|
|
15131
|
-
let description = "";
|
|
15132
|
-
if (typeof desc === "string") {
|
|
15133
|
-
description = desc;
|
|
15134
|
-
} else if (typeof desc === "function") {
|
|
15135
|
-
description = desc() || "";
|
|
15136
|
-
}
|
|
15137
|
-
return new Route("", "", { description });
|
|
15135
|
+
prompt(description) {
|
|
15136
|
+
return new Route(undefined, undefined, { description });
|
|
15138
15137
|
}
|
|
15139
15138
|
async run(msg, ctx) {
|
|
15140
15139
|
const handle = this.handle;
|
|
@@ -15491,7 +15490,221 @@ function filter(data, query) {
|
|
|
15491
15490
|
// node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.mjs
|
|
15492
15491
|
var import__2 = __toESM(require_eventemitter32(), 1);
|
|
15493
15492
|
|
|
15494
|
-
// node_modules/.pnpm/es-toolkit@1.
|
|
15493
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs
|
|
15494
|
+
function isPrimitive(value) {
|
|
15495
|
+
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
15496
|
+
}
|
|
15497
|
+
|
|
15498
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
|
|
15499
|
+
function isTypedArray(x) {
|
|
15500
|
+
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
15501
|
+
}
|
|
15502
|
+
|
|
15503
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
|
|
15504
|
+
function getSymbols(object2) {
|
|
15505
|
+
return Object.getOwnPropertySymbols(object2).filter((symbol2) => Object.prototype.propertyIsEnumerable.call(object2, symbol2));
|
|
15506
|
+
}
|
|
15507
|
+
|
|
15508
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
|
|
15509
|
+
function getTag(value) {
|
|
15510
|
+
if (value == null) {
|
|
15511
|
+
return value === undefined ? "[object Undefined]" : "[object Null]";
|
|
15512
|
+
}
|
|
15513
|
+
return Object.prototype.toString.call(value);
|
|
15514
|
+
}
|
|
15515
|
+
|
|
15516
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/tags.mjs
|
|
15517
|
+
var regexpTag = "[object RegExp]";
|
|
15518
|
+
var stringTag = "[object String]";
|
|
15519
|
+
var numberTag = "[object Number]";
|
|
15520
|
+
var booleanTag = "[object Boolean]";
|
|
15521
|
+
var argumentsTag = "[object Arguments]";
|
|
15522
|
+
var symbolTag = "[object Symbol]";
|
|
15523
|
+
var dateTag = "[object Date]";
|
|
15524
|
+
var mapTag = "[object Map]";
|
|
15525
|
+
var setTag = "[object Set]";
|
|
15526
|
+
var arrayTag = "[object Array]";
|
|
15527
|
+
var arrayBufferTag = "[object ArrayBuffer]";
|
|
15528
|
+
var objectTag = "[object Object]";
|
|
15529
|
+
var dataViewTag = "[object DataView]";
|
|
15530
|
+
var uint8ArrayTag = "[object Uint8Array]";
|
|
15531
|
+
var uint8ClampedArrayTag = "[object Uint8ClampedArray]";
|
|
15532
|
+
var uint16ArrayTag = "[object Uint16Array]";
|
|
15533
|
+
var uint32ArrayTag = "[object Uint32Array]";
|
|
15534
|
+
var int8ArrayTag = "[object Int8Array]";
|
|
15535
|
+
var int16ArrayTag = "[object Int16Array]";
|
|
15536
|
+
var int32ArrayTag = "[object Int32Array]";
|
|
15537
|
+
var float32ArrayTag = "[object Float32Array]";
|
|
15538
|
+
var float64ArrayTag = "[object Float64Array]";
|
|
15539
|
+
|
|
15540
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/cloneDeepWith.mjs
|
|
15541
|
+
function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new Map, cloneValue = undefined) {
|
|
15542
|
+
const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
|
|
15543
|
+
if (cloned !== undefined) {
|
|
15544
|
+
return cloned;
|
|
15545
|
+
}
|
|
15546
|
+
if (isPrimitive(valueToClone)) {
|
|
15547
|
+
return valueToClone;
|
|
15548
|
+
}
|
|
15549
|
+
if (stack.has(valueToClone)) {
|
|
15550
|
+
return stack.get(valueToClone);
|
|
15551
|
+
}
|
|
15552
|
+
if (Array.isArray(valueToClone)) {
|
|
15553
|
+
const result = new Array(valueToClone.length);
|
|
15554
|
+
stack.set(valueToClone, result);
|
|
15555
|
+
for (let i = 0;i < valueToClone.length; i++) {
|
|
15556
|
+
result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
|
15557
|
+
}
|
|
15558
|
+
if (Object.hasOwn(valueToClone, "index")) {
|
|
15559
|
+
result.index = valueToClone.index;
|
|
15560
|
+
}
|
|
15561
|
+
if (Object.hasOwn(valueToClone, "input")) {
|
|
15562
|
+
result.input = valueToClone.input;
|
|
15563
|
+
}
|
|
15564
|
+
return result;
|
|
15565
|
+
}
|
|
15566
|
+
if (valueToClone instanceof Date) {
|
|
15567
|
+
return new Date(valueToClone.getTime());
|
|
15568
|
+
}
|
|
15569
|
+
if (valueToClone instanceof RegExp) {
|
|
15570
|
+
const result = new RegExp(valueToClone.source, valueToClone.flags);
|
|
15571
|
+
result.lastIndex = valueToClone.lastIndex;
|
|
15572
|
+
return result;
|
|
15573
|
+
}
|
|
15574
|
+
if (valueToClone instanceof Map) {
|
|
15575
|
+
const result = new Map;
|
|
15576
|
+
stack.set(valueToClone, result);
|
|
15577
|
+
for (const [key, value] of valueToClone) {
|
|
15578
|
+
result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
|
|
15579
|
+
}
|
|
15580
|
+
return result;
|
|
15581
|
+
}
|
|
15582
|
+
if (valueToClone instanceof Set) {
|
|
15583
|
+
const result = new Set;
|
|
15584
|
+
stack.set(valueToClone, result);
|
|
15585
|
+
for (const value of valueToClone) {
|
|
15586
|
+
result.add(cloneDeepWithImpl(value, undefined, objectToClone, stack, cloneValue));
|
|
15587
|
+
}
|
|
15588
|
+
return result;
|
|
15589
|
+
}
|
|
15590
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(valueToClone)) {
|
|
15591
|
+
return valueToClone.subarray();
|
|
15592
|
+
}
|
|
15593
|
+
if (isTypedArray(valueToClone)) {
|
|
15594
|
+
const result = new (Object.getPrototypeOf(valueToClone)).constructor(valueToClone.length);
|
|
15595
|
+
stack.set(valueToClone, result);
|
|
15596
|
+
for (let i = 0;i < valueToClone.length; i++) {
|
|
15597
|
+
result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
|
15598
|
+
}
|
|
15599
|
+
return result;
|
|
15600
|
+
}
|
|
15601
|
+
if (valueToClone instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && valueToClone instanceof SharedArrayBuffer) {
|
|
15602
|
+
return valueToClone.slice(0);
|
|
15603
|
+
}
|
|
15604
|
+
if (valueToClone instanceof DataView) {
|
|
15605
|
+
const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
|
|
15606
|
+
stack.set(valueToClone, result);
|
|
15607
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15608
|
+
return result;
|
|
15609
|
+
}
|
|
15610
|
+
if (typeof File !== "undefined" && valueToClone instanceof File) {
|
|
15611
|
+
const result = new File([valueToClone], valueToClone.name, {
|
|
15612
|
+
type: valueToClone.type
|
|
15613
|
+
});
|
|
15614
|
+
stack.set(valueToClone, result);
|
|
15615
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15616
|
+
return result;
|
|
15617
|
+
}
|
|
15618
|
+
if (typeof Blob !== "undefined" && valueToClone instanceof Blob) {
|
|
15619
|
+
const result = new Blob([valueToClone], { type: valueToClone.type });
|
|
15620
|
+
stack.set(valueToClone, result);
|
|
15621
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15622
|
+
return result;
|
|
15623
|
+
}
|
|
15624
|
+
if (valueToClone instanceof Error) {
|
|
15625
|
+
const result = structuredClone(valueToClone);
|
|
15626
|
+
stack.set(valueToClone, result);
|
|
15627
|
+
result.message = valueToClone.message;
|
|
15628
|
+
result.name = valueToClone.name;
|
|
15629
|
+
result.stack = valueToClone.stack;
|
|
15630
|
+
result.cause = valueToClone.cause;
|
|
15631
|
+
result.constructor = valueToClone.constructor;
|
|
15632
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15633
|
+
return result;
|
|
15634
|
+
}
|
|
15635
|
+
if (valueToClone instanceof Boolean) {
|
|
15636
|
+
const result = new Boolean(valueToClone.valueOf());
|
|
15637
|
+
stack.set(valueToClone, result);
|
|
15638
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15639
|
+
return result;
|
|
15640
|
+
}
|
|
15641
|
+
if (valueToClone instanceof Number) {
|
|
15642
|
+
const result = new Number(valueToClone.valueOf());
|
|
15643
|
+
stack.set(valueToClone, result);
|
|
15644
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15645
|
+
return result;
|
|
15646
|
+
}
|
|
15647
|
+
if (valueToClone instanceof String) {
|
|
15648
|
+
const result = new String(valueToClone.valueOf());
|
|
15649
|
+
stack.set(valueToClone, result);
|
|
15650
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15651
|
+
return result;
|
|
15652
|
+
}
|
|
15653
|
+
if (typeof valueToClone === "object" && isCloneableObject(valueToClone)) {
|
|
15654
|
+
const result = Object.create(Object.getPrototypeOf(valueToClone));
|
|
15655
|
+
stack.set(valueToClone, result);
|
|
15656
|
+
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
15657
|
+
return result;
|
|
15658
|
+
}
|
|
15659
|
+
return valueToClone;
|
|
15660
|
+
}
|
|
15661
|
+
function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
|
|
15662
|
+
const keys = [...Object.keys(source), ...getSymbols(source)];
|
|
15663
|
+
for (let i = 0;i < keys.length; i++) {
|
|
15664
|
+
const key = keys[i];
|
|
15665
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
15666
|
+
if (descriptor == null || descriptor.writable) {
|
|
15667
|
+
target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
|
|
15668
|
+
}
|
|
15669
|
+
}
|
|
15670
|
+
}
|
|
15671
|
+
function isCloneableObject(object2) {
|
|
15672
|
+
switch (getTag(object2)) {
|
|
15673
|
+
case argumentsTag:
|
|
15674
|
+
case arrayTag:
|
|
15675
|
+
case arrayBufferTag:
|
|
15676
|
+
case dataViewTag:
|
|
15677
|
+
case booleanTag:
|
|
15678
|
+
case dateTag:
|
|
15679
|
+
case float32ArrayTag:
|
|
15680
|
+
case float64ArrayTag:
|
|
15681
|
+
case int8ArrayTag:
|
|
15682
|
+
case int16ArrayTag:
|
|
15683
|
+
case int32ArrayTag:
|
|
15684
|
+
case mapTag:
|
|
15685
|
+
case numberTag:
|
|
15686
|
+
case objectTag:
|
|
15687
|
+
case regexpTag:
|
|
15688
|
+
case setTag:
|
|
15689
|
+
case stringTag:
|
|
15690
|
+
case symbolTag:
|
|
15691
|
+
case uint8ArrayTag:
|
|
15692
|
+
case uint8ClampedArrayTag:
|
|
15693
|
+
case uint16ArrayTag:
|
|
15694
|
+
case uint32ArrayTag: {
|
|
15695
|
+
return true;
|
|
15696
|
+
}
|
|
15697
|
+
default: {
|
|
15698
|
+
return false;
|
|
15699
|
+
}
|
|
15700
|
+
}
|
|
15701
|
+
}
|
|
15702
|
+
|
|
15703
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/cloneDeep.mjs
|
|
15704
|
+
function cloneDeep(obj) {
|
|
15705
|
+
return cloneDeepWithImpl(obj, undefined, obj, new Map, undefined);
|
|
15706
|
+
}
|
|
15707
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isBrowser.mjs
|
|
15495
15708
|
function isBrowser() {
|
|
15496
15709
|
return typeof window !== "undefined" && window?.document != null;
|
|
15497
15710
|
}
|
|
@@ -15502,6 +15715,9 @@ var initApi = async (opts) => {
|
|
|
15502
15715
|
const token = opts?.token;
|
|
15503
15716
|
const query = item?.api?.query || new Query({ url: item?.api?.url || "/api/router" });
|
|
15504
15717
|
const res = await query.post({ path: "router", key: "list", token });
|
|
15718
|
+
if (item) {
|
|
15719
|
+
item.routerStatus = res?.code === 200 ? "active" : "error";
|
|
15720
|
+
}
|
|
15505
15721
|
if (res.code !== 200) {
|
|
15506
15722
|
return {
|
|
15507
15723
|
code: res.code,
|
|
@@ -15548,7 +15764,7 @@ var initApi = async (opts) => {
|
|
|
15548
15764
|
|
|
15549
15765
|
// node_modules/.pnpm/fuse.js@7.1.0/node_modules/fuse.js/dist/fuse.mjs
|
|
15550
15766
|
function isArray(value) {
|
|
15551
|
-
return !Array.isArray ?
|
|
15767
|
+
return !Array.isArray ? getTag2(value) === "[object Array]" : Array.isArray(value);
|
|
15552
15768
|
}
|
|
15553
15769
|
var INFINITY = 1 / 0;
|
|
15554
15770
|
function baseToString(value) {
|
|
@@ -15568,7 +15784,7 @@ function isNumber(value) {
|
|
|
15568
15784
|
return typeof value === "number";
|
|
15569
15785
|
}
|
|
15570
15786
|
function isBoolean(value) {
|
|
15571
|
-
return value === true || value === false || isObjectLike(value) &&
|
|
15787
|
+
return value === true || value === false || isObjectLike(value) && getTag2(value) == "[object Boolean]";
|
|
15572
15788
|
}
|
|
15573
15789
|
function isObject2(value) {
|
|
15574
15790
|
return typeof value === "object";
|
|
@@ -15582,7 +15798,7 @@ function isDefined(value) {
|
|
|
15582
15798
|
function isBlank(value) {
|
|
15583
15799
|
return !value.trim().length;
|
|
15584
15800
|
}
|
|
15585
|
-
function
|
|
15801
|
+
function getTag2(value) {
|
|
15586
15802
|
return value == null ? value === undefined ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
|
|
15587
15803
|
}
|
|
15588
15804
|
var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
|
|
@@ -16843,7 +17059,7 @@ Fuse.config = Config;
|
|
|
16843
17059
|
// query/query-proxy/proxy.ts
|
|
16844
17060
|
var RouteTypeList = ["api", "context", "worker", "page"];
|
|
16845
17061
|
var pickRouterViewData = (item) => {
|
|
16846
|
-
const { action, response, _id, ...rest } = item;
|
|
17062
|
+
const { action, response, _id, ...rest } = cloneDeep(item);
|
|
16847
17063
|
if (rest.type === "api") {
|
|
16848
17064
|
if (rest.api) {
|
|
16849
17065
|
delete rest.api.query;
|
|
@@ -16859,6 +17075,7 @@ var pickRouterViewData = (item) => {
|
|
|
16859
17075
|
delete rest.context.router;
|
|
16860
17076
|
}
|
|
16861
17077
|
}
|
|
17078
|
+
delete rest.routerStatus;
|
|
16862
17079
|
return rest;
|
|
16863
17080
|
};
|
|
16864
17081
|
|
|
@@ -16894,6 +17111,7 @@ class QueryProxy {
|
|
|
16894
17111
|
});
|
|
16895
17112
|
}
|
|
16896
17113
|
initRouterView(item) {
|
|
17114
|
+
item.routerStatus = "loading";
|
|
16897
17115
|
if (item.type === "api" && item.api?.url) {
|
|
16898
17116
|
const url2 = item.api.url;
|
|
16899
17117
|
if (item?.api?.query)
|
|
@@ -16983,6 +17201,9 @@ class QueryProxy {
|
|
|
16983
17201
|
async initContext(item) {
|
|
16984
17202
|
const context = globalThis["context"] || {};
|
|
16985
17203
|
const router = item?.context?.router || context[item?.context?.key];
|
|
17204
|
+
if (item) {
|
|
17205
|
+
item.routerStatus = router ? "active" : "error";
|
|
17206
|
+
}
|
|
16986
17207
|
if (!router) {
|
|
16987
17208
|
console.warn(`未发现Context router ${item?.context?.key}`);
|
|
16988
17209
|
return;
|
|
@@ -17044,6 +17265,9 @@ class QueryProxy {
|
|
|
17044
17265
|
}
|
|
17045
17266
|
const viewItem = item.worker;
|
|
17046
17267
|
const worker = viewItem?.worker;
|
|
17268
|
+
if (item) {
|
|
17269
|
+
item.routerStatus = worker ? "active" : "error";
|
|
17270
|
+
}
|
|
17047
17271
|
if (!worker) {
|
|
17048
17272
|
console.warn("Worker not initialized");
|
|
17049
17273
|
return;
|
|
@@ -17111,11 +17335,15 @@ class QueryProxy {
|
|
|
17111
17335
|
const url2 = item.page.url;
|
|
17112
17336
|
try {
|
|
17113
17337
|
if (typeof window !== "undefined") {
|
|
17114
|
-
await import(url2)
|
|
17115
|
-
|
|
17116
|
-
|
|
17338
|
+
await import(url2);
|
|
17339
|
+
if (item) {
|
|
17340
|
+
item.routerStatus = "active";
|
|
17341
|
+
}
|
|
17117
17342
|
}
|
|
17118
17343
|
} catch (e) {
|
|
17344
|
+
if (item) {
|
|
17345
|
+
item.routerStatus = "error";
|
|
17346
|
+
}
|
|
17119
17347
|
console.warn("引入Page脚本失败:", url2, e);
|
|
17120
17348
|
return;
|
|
17121
17349
|
}
|
package/dist/query-resources.js
CHANGED
|
@@ -446,7 +446,7 @@ var require_spark_md5 = __commonJS((exports, module) => {
|
|
|
446
446
|
});
|
|
447
447
|
});
|
|
448
448
|
|
|
449
|
-
// node_modules/@kevisual/query/dist/query-browser.js
|
|
449
|
+
// node_modules/.pnpm/@kevisual+query@0.0.52/node_modules/@kevisual/query/dist/query-browser.js
|
|
450
450
|
var isTextForContentType = (contentType) => {
|
|
451
451
|
if (!contentType)
|
|
452
452
|
return false;
|
package/dist/query-secret.js
CHANGED
package/dist/query-shop.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/@kevisual/query/dist/query-browser.js
|
|
1
|
+
// node_modules/.pnpm/@kevisual+query@0.0.52/node_modules/@kevisual/query/dist/query-browser.js
|
|
2
2
|
var isTextForContentType = (contentType) => {
|
|
3
3
|
if (!contentType)
|
|
4
4
|
return false;
|
|
@@ -286,7 +286,7 @@ class Query {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
// node_modules/@kevisual/router/dist/router-define.js
|
|
289
|
+
// node_modules/.pnpm/@kevisual+router@0.0.85/node_modules/@kevisual/router/dist/router-define.js
|
|
290
290
|
class Chain {
|
|
291
291
|
object;
|
|
292
292
|
app;
|
|
@@ -435,7 +435,7 @@ var shopDefine = QueryUtil.create({
|
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
437
|
|
|
438
|
-
// node_modules/@kevisual/query/dist/query.js
|
|
438
|
+
// node_modules/.pnpm/@kevisual+query@0.0.52/node_modules/@kevisual/query/dist/query.js
|
|
439
439
|
class BaseQuery {
|
|
440
440
|
query;
|
|
441
441
|
queryDefine;
|
package/dist/store-mark.js
CHANGED
|
@@ -364,7 +364,7 @@ class QueryMark extends QueryMarkBase {
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
// node_modules/.pnpm/es-toolkit@1.
|
|
367
|
+
// node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/uniqBy.mjs
|
|
368
368
|
function uniqBy(arr, mapper) {
|
|
369
369
|
const map = new Map;
|
|
370
370
|
for (let i = 0;i < arr.length; i++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "mod.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"packageManager": "pnpm@10.30.
|
|
21
|
+
"packageManager": "pnpm@10.30.3",
|
|
22
22
|
"type": "module",
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@kevisual/cache": "^0.0.5",
|
|
25
25
|
"@kevisual/code-builder": "^0.0.6",
|
|
26
|
-
"@kevisual/query": "^0.0.
|
|
26
|
+
"@kevisual/query": "^0.0.52",
|
|
27
27
|
"@kevisual/remote-app": "^0.0.4",
|
|
28
|
-
"@kevisual/router": "^0.0.
|
|
28
|
+
"@kevisual/router": "^0.0.85",
|
|
29
29
|
"@kevisual/types": "^0.0.12",
|
|
30
30
|
"@kevisual/use-config": "^1.0.30",
|
|
31
|
-
"@types/bun": "^1.3.
|
|
32
|
-
"@types/node": "^25.3.
|
|
31
|
+
"@types/bun": "^1.3.10",
|
|
32
|
+
"@types/node": "^25.3.3",
|
|
33
33
|
"@types/spark-md5": "^3.0.5",
|
|
34
34
|
"dotenv": "^17.3.1",
|
|
35
35
|
"fast-glob": "^3.3.3",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@kevisual/js-filter": "^0.0.5",
|
|
41
41
|
"@kevisual/load": "^0.0.6",
|
|
42
42
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
43
|
-
"es-toolkit": "^1.
|
|
43
|
+
"es-toolkit": "^1.45.1",
|
|
44
44
|
"eventemitter3": "^5.0.4",
|
|
45
45
|
"fuse.js": "^7.1.0",
|
|
46
46
|
"nanoid": "^5.1.6",
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { createStore, UseStore, get, set, del, clear, keys, values, entries, update, setMany, getMany, delMany } from 'idb-keyval';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 缓存存储选项
|
|
5
|
+
*/
|
|
6
|
+
export type CacheStoreOpts = {
|
|
7
|
+
/**
|
|
8
|
+
* 数据库名称
|
|
9
|
+
*/
|
|
10
|
+
dbName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 存储空间名称
|
|
13
|
+
*/
|
|
14
|
+
storeName?: string;
|
|
15
|
+
};
|
|
16
|
+
export class BaseCacheStore {
|
|
17
|
+
store: UseStore;
|
|
18
|
+
constructor(opts?: CacheStoreOpts) {
|
|
19
|
+
this.store = createStore(opts?.dbName || 'default-db', opts?.storeName || 'cache-store');
|
|
20
|
+
}
|
|
21
|
+
async get(key: string) {
|
|
22
|
+
return get(key, this.store);
|
|
23
|
+
}
|
|
24
|
+
async set(key: string, value: any) {
|
|
25
|
+
return set(key, value, this.store);
|
|
26
|
+
}
|
|
27
|
+
async del(key: string) {
|
|
28
|
+
return del(key, this.store);
|
|
29
|
+
}
|
|
30
|
+
async clear() {
|
|
31
|
+
return clear(this.store);
|
|
32
|
+
}
|
|
33
|
+
async keys() {
|
|
34
|
+
return keys(this.store);
|
|
35
|
+
}
|
|
36
|
+
async values() {
|
|
37
|
+
return values(this.store);
|
|
38
|
+
}
|
|
39
|
+
async entries() {
|
|
40
|
+
return entries(this.store);
|
|
41
|
+
}
|
|
42
|
+
async update(key: string, updater: (value: any) => any) {
|
|
43
|
+
return update(key, updater, this.store);
|
|
44
|
+
}
|
|
45
|
+
async setMany(entries: [string, any][]) {
|
|
46
|
+
return setMany(entries, this.store);
|
|
47
|
+
}
|
|
48
|
+
async getMany(keys: string[]) {
|
|
49
|
+
return getMany(keys, this.store);
|
|
50
|
+
}
|
|
51
|
+
async delMany(keys: string[]) {
|
|
52
|
+
return delMany(keys, this.store);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 缓存存储
|
|
58
|
+
*/
|
|
59
|
+
export class CacheStore extends BaseCacheStore {
|
|
60
|
+
constructor(opts?: CacheStoreOpts) {
|
|
61
|
+
super(opts);
|
|
62
|
+
}
|
|
63
|
+
async getData<T = any>(key: string) {
|
|
64
|
+
const data = await this.get(key);
|
|
65
|
+
return data.data as T;
|
|
66
|
+
}
|
|
67
|
+
async setData(key: string, data: any) {
|
|
68
|
+
return this.set(key, data);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 获取缓存数据,并检查是否过期
|
|
72
|
+
* @param key 缓存键
|
|
73
|
+
* @returns 缓存数据
|
|
74
|
+
*/
|
|
75
|
+
async getCheckData<T = any>(key: string) {
|
|
76
|
+
const data = await this.get(key);
|
|
77
|
+
if (data.expireTime && data.expireTime < Date.now()) {
|
|
78
|
+
await super.del(key);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return data.data as T;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 设置缓存数据,并检查是否过期
|
|
85
|
+
* @param key 缓存键
|
|
86
|
+
* @param data 缓存数据
|
|
87
|
+
* @param opts 缓存选项
|
|
88
|
+
* @returns 缓存数据
|
|
89
|
+
*/
|
|
90
|
+
async setCheckData(key: string, data: any, opts?: { expireTime?: number; updatedAt?: number }) {
|
|
91
|
+
const now = Date.now();
|
|
92
|
+
const expireTime = now + (opts?.expireTime || 1000 * 60 * 60 * 24 * 10);
|
|
93
|
+
const newData = {
|
|
94
|
+
data,
|
|
95
|
+
updatedAt: opts?.updatedAt || Date.now(),
|
|
96
|
+
expireTime,
|
|
97
|
+
};
|
|
98
|
+
await this.set(key, newData);
|
|
99
|
+
return data;
|
|
100
|
+
}
|
|
101
|
+
async checkNew(key: string, data: any): Promise<boolean> {
|
|
102
|
+
const existing = await this.get(key);
|
|
103
|
+
if (!existing) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (!data?.updatedAt) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const updatedAt = new Date(data.updatedAt).getTime();
|
|
110
|
+
if (isNaN(updatedAt)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return updatedAt > existing.updatedAt;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 删除缓存数据
|
|
117
|
+
* @param key 缓存键
|
|
118
|
+
* @returns 缓存数据
|
|
119
|
+
*/
|
|
120
|
+
async delCheckData(key: string) {
|
|
121
|
+
return this.del(key);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { CacheStore, BaseCacheStore } from './cache-store.ts'
|
|
2
|
+
import { CacheStore } from './cache-store.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 一个简单的缓存类,用于存储字符串。
|
|
6
|
+
* 对数据进行添加对比内容。
|
|
7
|
+
*/
|
|
8
|
+
export class MyCache<T = any> extends CacheStore {
|
|
9
|
+
key: string;
|
|
10
|
+
constructor(opts?: { key?: string }) {
|
|
11
|
+
const { key, ...rest } = opts || {};
|
|
12
|
+
super(rest);
|
|
13
|
+
this.key = key || 'my-cache';
|
|
14
|
+
}
|
|
15
|
+
async getData<U = T>(key: string = this.key): Promise<U> {
|
|
16
|
+
return super.getCheckData<U>(key) as any;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 设置缓存数据,默认过期时间为10天
|
|
20
|
+
* @param data
|
|
21
|
+
* @param opts
|
|
22
|
+
*/
|
|
23
|
+
async setData<U = T>(data: U, opts?: { expireTime?: number, updatedAt?: number }) {
|
|
24
|
+
super.setCheckData(this.key, data, opts);
|
|
25
|
+
}
|
|
26
|
+
async del(): Promise<void> {
|
|
27
|
+
await super.del(this.key);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -146,19 +146,21 @@ export class LoginCacheStore<T extends Cache = Cache> implements CacheStore<T> {
|
|
|
146
146
|
/**
|
|
147
147
|
* 初始化,设置默认值
|
|
148
148
|
*/
|
|
149
|
-
async init() {
|
|
149
|
+
async init(): Promise<CacheLogin> {
|
|
150
150
|
const defaultData: CacheLogin = { ...this.cacheData };
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
return new Promise(async (resolve) => {
|
|
152
|
+
if (this.cache.init) {
|
|
153
|
+
try {
|
|
154
|
+
const cacheData = await this.cache.init();
|
|
155
|
+
this.cacheData = cacheData || defaultData;
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.log('cacheInit error', error);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
this.cacheData = (await this.getValue()) || defaultData;
|
|
157
161
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
return this.cacheData;
|
|
162
|
+
resolve(this.cacheData);
|
|
163
|
+
});
|
|
162
164
|
}
|
|
163
165
|
/**
|
|
164
166
|
* 设置当前用户
|