@ahoo-wang/fetcher-react 3.15.3 → 3.15.4
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/dataMonitor/DataMonitorService.d.ts +21 -0
- package/dist/dataMonitor/DataMonitorService.d.ts.map +1 -0
- package/dist/dataMonitor/index.d.ts +4 -0
- package/dist/dataMonitor/index.d.ts.map +1 -0
- package/dist/dataMonitor/useDataMonitor.d.ts +18 -0
- package/dist/dataMonitor/useDataMonitor.d.ts.map +1 -0
- package/dist/dataMonitor/useDataMonitorEventBus.d.ts +17 -0
- package/dist/dataMonitor/useDataMonitorEventBus.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +274 -45
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Condition } from '@ahoo-wang/fetcher-wow';
|
|
2
|
+
export interface DataMonitorNotificationConfig {
|
|
3
|
+
title: string;
|
|
4
|
+
navigationUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class DataMonitorService {
|
|
7
|
+
private monitoredViews;
|
|
8
|
+
private storage;
|
|
9
|
+
initialize(): void;
|
|
10
|
+
enable(viewId: string, countUrl: string, viewName: string, condition: Condition, notification: DataMonitorNotificationConfig, interval?: number): void;
|
|
11
|
+
disable(viewId: string): void;
|
|
12
|
+
updateCondition(viewId: string, condition: Condition): void;
|
|
13
|
+
updateNotification(viewId: string, notification: DataMonitorNotificationConfig): void;
|
|
14
|
+
isEnabled(viewId: string): boolean;
|
|
15
|
+
private fetchAndCheck;
|
|
16
|
+
private fetchCount;
|
|
17
|
+
private notify;
|
|
18
|
+
private saveToStorage;
|
|
19
|
+
}
|
|
20
|
+
export declare const dataMonitorService: DataMonitorService;
|
|
21
|
+
//# sourceMappingURL=DataMonitorService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataMonitorService.d.ts","sourceRoot":"","sources":["../../src/dataMonitor/DataMonitorService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAKxD,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAsBD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,OAAO,CAGZ;IAEH,UAAU,IAAI,IAAI;IAelB,MAAM,CACJ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,6BAA6B,EAC3C,QAAQ,GAAE,MAAc,GACvB,IAAI;IA2BP,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAW7B,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAQ3D,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,6BAA6B,GAAG,IAAI;IAQrF,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;YAIpB,aAAa;YAgCb,UAAU;IAOxB,OAAO,CAAC,MAAM;IAsBd,OAAO,CAAC,aAAa;CAatB;AAED,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dataMonitor/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Condition } from '@ahoo-wang/fetcher-wow';
|
|
2
|
+
import { DataMonitorNotificationConfig } from './DataMonitorService';
|
|
3
|
+
export interface UseDataMonitorOptions {
|
|
4
|
+
viewId: string;
|
|
5
|
+
countUrl: string;
|
|
6
|
+
viewName: string;
|
|
7
|
+
condition: Condition;
|
|
8
|
+
notification: DataMonitorNotificationConfig;
|
|
9
|
+
interval?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface UseDataMonitorReturn {
|
|
12
|
+
isEnabled: boolean;
|
|
13
|
+
enable: () => void;
|
|
14
|
+
disable: () => void;
|
|
15
|
+
toggle: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function useDataMonitor(options: UseDataMonitorOptions): UseDataMonitorReturn;
|
|
18
|
+
//# sourceMappingURL=useDataMonitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataMonitor.d.ts","sourceRoot":"","sources":["../../src/dataMonitor/useDataMonitor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,6BAA6B,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,qBAAqB,GAC7B,oBAAoB,CA8DtB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EventHandler } from '@ahoo-wang/fetcher-eventbus';
|
|
2
|
+
export interface DataChangedEvent {
|
|
3
|
+
type: 'DATA_CHANGED';
|
|
4
|
+
viewId: string;
|
|
5
|
+
viewName: string;
|
|
6
|
+
previousTotal: number | null;
|
|
7
|
+
currentTotal: number;
|
|
8
|
+
}
|
|
9
|
+
export interface UseDataMonitorEventBusReturn {
|
|
10
|
+
subscribe: (handler: EventHandler<DataChangedEvent>) => boolean;
|
|
11
|
+
unsubscribe: (handlerName: string) => boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function useDataMonitorEventBus(): UseDataMonitorEventBusReturn;
|
|
14
|
+
export declare const dataMonitorEventBus: {
|
|
15
|
+
emit: (event: DataChangedEvent) => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useDataMonitorEventBus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDataMonitorEventBus.d.ts","sourceRoot":"","sources":["../../src/dataMonitor/useDataMonitorEventBus.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAIhE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,gBAAgB,CAAC,KAAK,OAAO,CAAC;IAChE,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;CAC/C;AAKD,wBAAgB,sBAAsB,IAAI,4BAA4B,CAarE;AAGD,eAAO,MAAM,mBAAmB;kBAChB,gBAAgB,KAAG,OAAO,CAAC,IAAI,CAAC;CAG/C,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { c as e } from "react/compiler-runtime";
|
|
2
2
|
import { createContext as t, useCallback as n, useContext as r, useEffect as i, useMemo as a, useReducer as o, useRef as s, useState as c, useSyncExternalStore as l } from "react";
|
|
3
3
|
import { Fragment as u, jsx as d } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
5
|
-
import { produce as
|
|
6
|
-
import { JsonResultExtractor as
|
|
7
|
-
import { JsonEventStreamResultExtractor as
|
|
4
|
+
import { BroadcastTypedEventBus as f, SerialTypedEventBus as p, nameGenerator as m } from "@ahoo-wang/fetcher-eventbus";
|
|
5
|
+
import { produce as h } from "immer";
|
|
6
|
+
import { JsonResultExtractor as g, fetcher as _, fetcherRegistrar as v, getFetcher as y } from "@ahoo-wang/fetcher";
|
|
7
|
+
import { JsonEventStreamResultExtractor as b } from "@ahoo-wang/fetcher-eventstream";
|
|
8
|
+
import { KeyStorage as x } from "@ahoo-wang/fetcher-storage";
|
|
8
9
|
//#region \0rolldown/runtime.js
|
|
9
|
-
var
|
|
10
|
+
var S = Object.defineProperty, __name = (e, t) => S(e, "name", {
|
|
10
11
|
value: t,
|
|
11
12
|
configurable: !0
|
|
12
13
|
});
|
|
@@ -103,15 +104,15 @@ function useMounted() {
|
|
|
103
104
|
}
|
|
104
105
|
//#endregion
|
|
105
106
|
//#region src/core/usePromiseState.ts
|
|
106
|
-
var
|
|
107
|
+
var C = /* @__PURE__ */ function(e) {
|
|
107
108
|
return e.IDLE = "idle", e.LOADING = "loading", e.SUCCESS = "success", e.ERROR = "error", e;
|
|
108
109
|
}({});
|
|
109
110
|
function usePromiseState(e) {
|
|
110
|
-
let [t, r] = c(e?.initialStatus ??
|
|
111
|
-
u() && (r(
|
|
111
|
+
let [t, r] = c(e?.initialStatus ?? C.IDLE), [i, o] = c(void 0), [s, l] = c(void 0), u = useMounted(), d = useLatest(e), f = n(() => {
|
|
112
|
+
u() && (r(C.LOADING), l(void 0));
|
|
112
113
|
}, [u]), p = n(async (e) => {
|
|
113
114
|
if (u()) {
|
|
114
|
-
o(e), r(
|
|
115
|
+
o(e), r(C.SUCCESS), l(void 0);
|
|
115
116
|
try {
|
|
116
117
|
await d.current?.onSuccess?.(e);
|
|
117
118
|
} catch (e) {
|
|
@@ -120,7 +121,7 @@ function usePromiseState(e) {
|
|
|
120
121
|
}
|
|
121
122
|
}, [u, d]), m = n(async (e) => {
|
|
122
123
|
if (u()) {
|
|
123
|
-
l(e), r(
|
|
124
|
+
l(e), r(C.ERROR), o(void 0);
|
|
124
125
|
try {
|
|
125
126
|
await d.current?.onError?.(e);
|
|
126
127
|
} catch (e) {
|
|
@@ -128,11 +129,11 @@ function usePromiseState(e) {
|
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
}, [u, d]), h = n(() => {
|
|
131
|
-
u() && (r(
|
|
132
|
+
u() && (r(C.IDLE), l(void 0), o(void 0));
|
|
132
133
|
}, [u]);
|
|
133
134
|
return a(() => ({
|
|
134
135
|
status: t,
|
|
135
|
-
loading: t ===
|
|
136
|
+
loading: t === C.LOADING,
|
|
136
137
|
result: i,
|
|
137
138
|
error: s,
|
|
138
139
|
setLoading: f,
|
|
@@ -357,7 +358,7 @@ async function _temp$1() {
|
|
|
357
358
|
__name(_temp$1, "_temp");
|
|
358
359
|
//#endregion
|
|
359
360
|
//#region src/core/fullscreen/FullscreenContext.tsx
|
|
360
|
-
var
|
|
361
|
+
var w = t(void 0);
|
|
361
362
|
function FullscreenProvider(t) {
|
|
362
363
|
let n = e(13), r, i, a;
|
|
363
364
|
n[0] === t ? (r = n[1], i = n[2], a = n[3]) : ({children: r, target: a, ...i} = t, n[0] = t, n[1] = r, n[2] = i, n[3] = a);
|
|
@@ -372,13 +373,13 @@ function FullscreenProvider(t) {
|
|
|
372
373
|
children: r
|
|
373
374
|
}), n[7] = r, n[8] = f, n[9] = p) : p = n[9];
|
|
374
375
|
let m;
|
|
375
|
-
return n[10] !== u || n[11] !== p ? (m = /* @__PURE__ */ d(
|
|
376
|
+
return n[10] !== u || n[11] !== p ? (m = /* @__PURE__ */ d(w.Provider, {
|
|
376
377
|
value: u,
|
|
377
378
|
children: p
|
|
378
379
|
}), n[10] = u, n[11] = p, n[12] = m) : m = n[12], m;
|
|
379
380
|
}
|
|
380
381
|
function useFullscreenContext() {
|
|
381
|
-
return r(
|
|
382
|
+
return r(w);
|
|
382
383
|
}
|
|
383
384
|
//#endregion
|
|
384
385
|
//#region src/core/useRefs.ts
|
|
@@ -535,7 +536,7 @@ function createQueryApiHooks(e) {
|
|
|
535
536
|
function useKeyStorage(t, n) {
|
|
536
537
|
let r = e(13), t0;
|
|
537
538
|
r[0] === t ? t0 = r[1] : (t0 = (e) => t.addListener({
|
|
538
|
-
name:
|
|
539
|
+
name: m.generate("useKeyStorage"),
|
|
539
540
|
handle: e
|
|
540
541
|
}), r[0] = t, r[1] = t0);
|
|
541
542
|
let i = t0, t1;
|
|
@@ -559,7 +560,7 @@ function useKeyStorage(t, n) {
|
|
|
559
560
|
function useImmerKeyStorage(t, n) {
|
|
560
561
|
let r = e(8), [i, a, o] = useKeyStorage(t, n), t0;
|
|
561
562
|
r[0] !== o || r[1] !== a || r[2] !== i ? (t0 = (e) => {
|
|
562
|
-
let t =
|
|
563
|
+
let t = h(i, e);
|
|
563
564
|
if (t === null) {
|
|
564
565
|
o();
|
|
565
566
|
return;
|
|
@@ -575,7 +576,7 @@ function useImmerKeyStorage(t, n) {
|
|
|
575
576
|
}
|
|
576
577
|
//#endregion
|
|
577
578
|
//#region src/cosec/useSecurity.ts
|
|
578
|
-
var
|
|
579
|
+
var T = {
|
|
579
580
|
jti: "",
|
|
580
581
|
sub: "anonymous",
|
|
581
582
|
iat: 0,
|
|
@@ -593,7 +594,7 @@ function useSecurity(t, n) {
|
|
|
593
594
|
r[5] !== c || r[6] !== s ? (t3 = () => {
|
|
594
595
|
s(), c.current.onSignOut?.();
|
|
595
596
|
}, r[5] = c, r[6] = s, r[7] = t3) : t3 = r[7];
|
|
596
|
-
let u = t3, d = o?.access?.payload ??
|
|
597
|
+
let u = t3, d = o?.access?.payload ?? T, f = o?.authenticated ?? !1, p;
|
|
597
598
|
return r[8] !== l || r[9] !== u || r[10] !== d || r[11] !== f ? (p = {
|
|
598
599
|
currentUser: d,
|
|
599
600
|
authenticated: f,
|
|
@@ -603,18 +604,18 @@ function useSecurity(t, n) {
|
|
|
603
604
|
}
|
|
604
605
|
//#endregion
|
|
605
606
|
//#region src/cosec/SecurityContext.tsx
|
|
606
|
-
var
|
|
607
|
+
var E = t(void 0);
|
|
607
608
|
function SecurityProvider(t) {
|
|
608
609
|
let n = e(7), r, i, a;
|
|
609
610
|
n[0] === t ? (r = n[1], i = n[2], a = n[3]) : ({tokenStorage: i, children: r, ...a} = t, n[0] = t, n[1] = r, n[2] = i, n[3] = a);
|
|
610
611
|
let o = useSecurity(i, a), s;
|
|
611
|
-
return n[4] !== r || n[5] !== o ? (s = /* @__PURE__ */ d(
|
|
612
|
+
return n[4] !== r || n[5] !== o ? (s = /* @__PURE__ */ d(E.Provider, {
|
|
612
613
|
value: o,
|
|
613
614
|
children: r
|
|
614
615
|
}), n[4] = r, n[5] = o, n[6] = s) : s = n[6], s;
|
|
615
616
|
}
|
|
616
617
|
function useSecurityContext() {
|
|
617
|
-
let e = r(
|
|
618
|
+
let e = r(E);
|
|
618
619
|
if (!e) throw Error("useSecurityContext must be used within a SecurityProvider");
|
|
619
620
|
return e;
|
|
620
621
|
}
|
|
@@ -660,28 +661,28 @@ function RefreshableRouteGuard(t) {
|
|
|
660
661
|
function useFetcher(t) {
|
|
661
662
|
let n = e(21), r;
|
|
662
663
|
n[0] === t ? r = n[1] : (r = t || {}, n[0] = t, n[1] = r);
|
|
663
|
-
let { fetcher: i } = r, a = i === void 0 ?
|
|
664
|
-
n[2] === a ?
|
|
665
|
-
let b =
|
|
666
|
-
n[4] !== b || n[5] !==
|
|
664
|
+
let { fetcher: i } = r, a = i === void 0 ? v.default : i, { loading: o, result: s, error: l, status: u, execute: d, reset: f, abort: p } = useExecutePromise(t), [m, h] = c(void 0), g = useLatest(t), _;
|
|
665
|
+
n[2] === a ? _ = n[3] : (_ = y(a), n[2] = a, n[3] = _);
|
|
666
|
+
let b = _, t3;
|
|
667
|
+
n[4] !== b || n[5] !== g || n[6] !== d ? (t3 = async (e) => {
|
|
667
668
|
try {
|
|
668
669
|
await d(async (t) => {
|
|
669
670
|
e.abortController = t;
|
|
670
|
-
let n = await b.exchange(e,
|
|
671
|
-
return
|
|
671
|
+
let n = await b.exchange(e, g.current);
|
|
672
|
+
return h(n), await n.extractResult();
|
|
672
673
|
});
|
|
673
674
|
} catch (e) {
|
|
674
675
|
let t = e;
|
|
675
|
-
throw
|
|
676
|
+
throw h(void 0), t;
|
|
676
677
|
}
|
|
677
|
-
}, n[4] = b, n[5] =
|
|
678
|
+
}, n[4] = b, n[5] = g, n[6] = d, n[7] = t3) : t3 = n[7];
|
|
678
679
|
let x = t3, t4;
|
|
679
680
|
n[8] === f ? t4 = n[9] : (t4 = () => {
|
|
680
|
-
f(),
|
|
681
|
+
f(), h(void 0);
|
|
681
682
|
}, n[8] = f, n[9] = t4);
|
|
682
683
|
let S = t4, t5;
|
|
683
684
|
n[10] === p ? t5 = n[11] : (t5 = () => {
|
|
684
|
-
p(),
|
|
685
|
+
p(), h(void 0);
|
|
685
686
|
}, n[10] = p, n[11] = t5);
|
|
686
687
|
let C = t5, w;
|
|
687
688
|
return n[12] !== C || n[13] !== l || n[14] !== m || n[15] !== x || n[16] !== o || n[17] !== S || n[18] !== s || n[19] !== u ? (w = {
|
|
@@ -748,7 +749,7 @@ function useDebouncedFetcherQuery(t) {
|
|
|
748
749
|
function useFetcherQuery(t) {
|
|
749
750
|
let n = e(23), r;
|
|
750
751
|
n[0] === t ? r = n[1] : (r = {
|
|
751
|
-
resultExtractor:
|
|
752
|
+
resultExtractor: g,
|
|
752
753
|
...t
|
|
753
754
|
}, n[0] = t, n[1] = r);
|
|
754
755
|
let i = r, a = useLatest(i), { loading: o, result: s, error: c, status: l, execute: u, reset: d, abort: f } = useFetcher(i), t1;
|
|
@@ -757,20 +758,20 @@ function useFetcherQuery(t) {
|
|
|
757
758
|
method: "POST",
|
|
758
759
|
body: e
|
|
759
760
|
}), n[2] = u, n[3] = a, n[4] = t1) : t1 = n[4];
|
|
760
|
-
let p = t1,
|
|
761
|
-
n[5] !== p || n[6] !== i.autoExecute || n[7] !== i.initialQuery || n[8] !== i.query ? (
|
|
761
|
+
let p = t1, m;
|
|
762
|
+
n[5] !== p || n[6] !== i.autoExecute || n[7] !== i.initialQuery || n[8] !== i.query ? (m = {
|
|
762
763
|
initialQuery: i.initialQuery,
|
|
763
764
|
query: i.query,
|
|
764
765
|
autoExecute: i.autoExecute,
|
|
765
766
|
execute: p
|
|
766
|
-
}, n[5] = p, n[6] = i.autoExecute, n[7] = i.initialQuery, n[8] = i.query, n[9] =
|
|
767
|
-
let { getQuery:
|
|
768
|
-
n[10] !== p || n[11] !==
|
|
769
|
-
let e =
|
|
767
|
+
}, n[5] = p, n[6] = i.autoExecute, n[7] = i.initialQuery, n[8] = i.query, n[9] = m) : m = n[9];
|
|
768
|
+
let { getQuery: h, setQuery: _ } = useQueryState(m), t3;
|
|
769
|
+
n[10] !== p || n[11] !== h ? (t3 = async () => {
|
|
770
|
+
let e = h();
|
|
770
771
|
if (isValidateQuery(e)) return await p(e);
|
|
771
|
-
}, n[10] = p, n[11] =
|
|
772
|
+
}, n[10] = p, n[11] = h, n[12] = t3) : t3 = n[12];
|
|
772
773
|
let v = t3, y;
|
|
773
|
-
return n[13] !== f || n[14] !== c || n[15] !== v || n[16] !==
|
|
774
|
+
return n[13] !== f || n[14] !== c || n[15] !== v || n[16] !== h || n[17] !== o || n[18] !== d || n[19] !== s || n[20] !== _ || n[21] !== l ? (y = {
|
|
774
775
|
loading: o,
|
|
775
776
|
result: s,
|
|
776
777
|
error: c,
|
|
@@ -778,9 +779,9 @@ function useFetcherQuery(t) {
|
|
|
778
779
|
execute: v,
|
|
779
780
|
reset: d,
|
|
780
781
|
abort: f,
|
|
781
|
-
getQuery:
|
|
782
|
+
getQuery: h,
|
|
782
783
|
setQuery: _
|
|
783
|
-
}, n[13] = f, n[14] = c, n[15] = v, n[16] =
|
|
784
|
+
}, n[13] = f, n[14] = c, n[15] = v, n[16] = h, n[17] = o, n[18] = d, n[19] = s, n[20] = _, n[21] = l, n[22] = y) : y = n[22], y;
|
|
784
785
|
}
|
|
785
786
|
//#endregion
|
|
786
787
|
//#region src/wow/fetcher/useFetcherCountQuery.ts
|
|
@@ -798,7 +799,7 @@ function useFetcherListStreamQuery(t) {
|
|
|
798
799
|
let n = e(2), r;
|
|
799
800
|
return n[0] === t ? r = n[1] : (r = {
|
|
800
801
|
...t,
|
|
801
|
-
resultExtractor:
|
|
802
|
+
resultExtractor: b
|
|
802
803
|
}, n[0] = t, n[1] = r), useFetcherQuery(r);
|
|
803
804
|
}
|
|
804
805
|
//#endregion
|
|
@@ -854,6 +855,234 @@ function useEventSubscription(t) {
|
|
|
854
855
|
}, n[10] = o, n[11] = s, n[12] = l) : l = n[12], l;
|
|
855
856
|
}
|
|
856
857
|
//#endregion
|
|
857
|
-
|
|
858
|
+
//#region src/notification/channel/browserNotification.ts
|
|
859
|
+
var D = "browser", BrowserNotificationChannel = class {
|
|
860
|
+
async send(e) {
|
|
861
|
+
try {
|
|
862
|
+
if (!this.isSupported()) return;
|
|
863
|
+
let t = window.Notification.permission;
|
|
864
|
+
if (t === "default" && (t = await this.requestPermission()), t !== "granted") {
|
|
865
|
+
console.warn("The user has not granted permission for notification");
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
let n = new Notification(e.title, e.payload);
|
|
869
|
+
e.onClick && n.addEventListener("click", e.onClick, { once: !0 });
|
|
870
|
+
} catch (e) {
|
|
871
|
+
console.error("send notification failed.", e);
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
requestPermission() {
|
|
876
|
+
if (!this.isSupported()) throw Error("The browser is not supported notification service");
|
|
877
|
+
return Notification.requestPermission();
|
|
878
|
+
}
|
|
879
|
+
isSupported() {
|
|
880
|
+
return "Notification" in window;
|
|
881
|
+
}
|
|
882
|
+
}, O = new BrowserNotificationChannel(), k = class NotificationChannelRegistry {
|
|
883
|
+
constructor() {
|
|
884
|
+
this.registry = /* @__PURE__ */ new Map();
|
|
885
|
+
}
|
|
886
|
+
get types() {
|
|
887
|
+
return Array.from(this.registry.keys());
|
|
888
|
+
}
|
|
889
|
+
get entries() {
|
|
890
|
+
return Array.from(this.registry.entries());
|
|
891
|
+
}
|
|
892
|
+
get size() {
|
|
893
|
+
return this.registry.size;
|
|
894
|
+
}
|
|
895
|
+
has(e) {
|
|
896
|
+
return this.registry.has(e);
|
|
897
|
+
}
|
|
898
|
+
clear() {
|
|
899
|
+
this.registry.clear();
|
|
900
|
+
}
|
|
901
|
+
register(e, t) {
|
|
902
|
+
if (this.registry.has(e)) throw Error(`Channel for type ${e} already registered.`);
|
|
903
|
+
this.registry.set(e, t);
|
|
904
|
+
}
|
|
905
|
+
unregister(e) {
|
|
906
|
+
this.registry.delete(e);
|
|
907
|
+
}
|
|
908
|
+
get(e) {
|
|
909
|
+
return this.registry.get(e);
|
|
910
|
+
}
|
|
911
|
+
static create(e = []) {
|
|
912
|
+
let t = new NotificationChannelRegistry();
|
|
913
|
+
return e.forEach(([e, n]) => t.register(e, n)), t;
|
|
914
|
+
}
|
|
915
|
+
}.create([[D, O]]), A = "NOTIFICATION_CENTER_EVENT", j = "NOTIFICATION_CENTER_EVENT_HANDLER", beforeUnloadHandler = () => {
|
|
916
|
+
M.destroy();
|
|
917
|
+
}, NotificationCenter = class {
|
|
918
|
+
constructor() {
|
|
919
|
+
this.eventBus = new f({ delegate: new p(A) }), this.eventBus.on({
|
|
920
|
+
name: j,
|
|
921
|
+
once: !1,
|
|
922
|
+
handle: async (e) => {
|
|
923
|
+
await this.sendNotification(e.type, e.message);
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
async sendNotification(e, t) {
|
|
928
|
+
let n = k.get(e);
|
|
929
|
+
if (!n) throw Error(`Channel ${e} is not registered`);
|
|
930
|
+
await n.send(t);
|
|
931
|
+
}
|
|
932
|
+
publish(e, t) {
|
|
933
|
+
return this.eventBus.emit({
|
|
934
|
+
type: e,
|
|
935
|
+
message: t
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
off() {
|
|
939
|
+
this.eventBus.off(j);
|
|
940
|
+
}
|
|
941
|
+
destroy() {
|
|
942
|
+
this.off(), this.eventBus.destroy();
|
|
943
|
+
}
|
|
944
|
+
}, M = new NotificationCenter();
|
|
945
|
+
window.addEventListener("beforeunload", beforeUnloadHandler);
|
|
946
|
+
//#endregion
|
|
947
|
+
//#region src/dataMonitor/useDataMonitorEventBus.ts
|
|
948
|
+
var N = new f({ delegate: new p("DATA_MONITOR_EVENT") });
|
|
949
|
+
function useDataMonitorEventBus() {
|
|
950
|
+
let subscribe = (e) => N.on(e), unsubscribe = (e) => N.off(e);
|
|
951
|
+
return {
|
|
952
|
+
subscribe,
|
|
953
|
+
unsubscribe
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
var P = { emit: (e) => N.emit(e) }, DataMonitorService = class {
|
|
957
|
+
constructor() {
|
|
958
|
+
this.monitoredViews = /* @__PURE__ */ new Map(), this.storage = new x({
|
|
959
|
+
key: "view:dataMonitor",
|
|
960
|
+
defaultValue: {}
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
initialize() {
|
|
964
|
+
let e = this.storage.get() || {};
|
|
965
|
+
for (let [t, n] of Object.entries(e)) n.enabled && this.enable(t, n.countUrl, n.viewName, n.condition, n.notification || { title: "" });
|
|
966
|
+
}
|
|
967
|
+
enable(e, t, n, r, i, a = 3e4) {
|
|
968
|
+
this.monitoredViews.has(e) && this.disable(e);
|
|
969
|
+
let o = {
|
|
970
|
+
enabled: !0,
|
|
971
|
+
countUrl: t,
|
|
972
|
+
viewName: n,
|
|
973
|
+
condition: r,
|
|
974
|
+
notification: i,
|
|
975
|
+
total: null,
|
|
976
|
+
intervalId: null
|
|
977
|
+
};
|
|
978
|
+
this.monitoredViews.set(e, o), this.fetchAndCheck(e), o.intervalId = window.setInterval(() => {
|
|
979
|
+
this.fetchAndCheck(e);
|
|
980
|
+
}, a), this.saveToStorage();
|
|
981
|
+
}
|
|
982
|
+
disable(e) {
|
|
983
|
+
let t = this.monitoredViews.get(e);
|
|
984
|
+
t && (t.intervalId !== null && window.clearInterval(t.intervalId), this.monitoredViews.delete(e), this.saveToStorage());
|
|
985
|
+
}
|
|
986
|
+
updateCondition(e, t) {
|
|
987
|
+
let n = this.monitoredViews.get(e);
|
|
988
|
+
n && (n.condition = t, this.saveToStorage());
|
|
989
|
+
}
|
|
990
|
+
updateNotification(e, t) {
|
|
991
|
+
let n = this.monitoredViews.get(e);
|
|
992
|
+
n && (n.notification = t, this.saveToStorage());
|
|
993
|
+
}
|
|
994
|
+
isEnabled(e) {
|
|
995
|
+
return this.monitoredViews.has(e);
|
|
996
|
+
}
|
|
997
|
+
async fetchAndCheck(e) {
|
|
998
|
+
let t = this.monitoredViews.get(e);
|
|
999
|
+
if (t) try {
|
|
1000
|
+
let n = await this.fetchCount(t.countUrl, t.condition), r = this.monitoredViews.get(e);
|
|
1001
|
+
if (!r) return;
|
|
1002
|
+
let i = r.total;
|
|
1003
|
+
i !== null && i !== n ? (r.total = n, this.notify(e, r.notification, n), await P.emit({
|
|
1004
|
+
type: "DATA_CHANGED",
|
|
1005
|
+
viewId: e,
|
|
1006
|
+
viewName: r.viewName,
|
|
1007
|
+
previousTotal: i,
|
|
1008
|
+
currentTotal: n
|
|
1009
|
+
})) : r.total = n;
|
|
1010
|
+
} catch (t) {
|
|
1011
|
+
console.error(`DataMonitor: failed to fetch count for ${e}`, t);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
async fetchCount(e, t) {
|
|
1015
|
+
return await _.post(e, { body: t });
|
|
1016
|
+
}
|
|
1017
|
+
notify(e, t, n) {
|
|
1018
|
+
let r = {
|
|
1019
|
+
title: t.title,
|
|
1020
|
+
payload: {
|
|
1021
|
+
body: `当前共 ${n} 条数据`,
|
|
1022
|
+
icon: "/logo.png"
|
|
1023
|
+
},
|
|
1024
|
+
onClick: () => {
|
|
1025
|
+
window.focus(), t.navigationUrl && (window.location.href = t.navigationUrl);
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
M.publish("browser", r);
|
|
1029
|
+
}
|
|
1030
|
+
saveToStorage() {
|
|
1031
|
+
let e = {};
|
|
1032
|
+
this.monitoredViews.forEach((t, n) => {
|
|
1033
|
+
e[n] = {
|
|
1034
|
+
enabled: t.enabled,
|
|
1035
|
+
countUrl: t.countUrl,
|
|
1036
|
+
viewName: t.viewName,
|
|
1037
|
+
condition: t.condition,
|
|
1038
|
+
notification: t.notification
|
|
1039
|
+
};
|
|
1040
|
+
}), this.storage.set(e);
|
|
1041
|
+
}
|
|
1042
|
+
}, F = new DataMonitorService();
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/dataMonitor/useDataMonitor.ts
|
|
1045
|
+
function useDataMonitor(t) {
|
|
1046
|
+
let n = e(33), { viewId: r, countUrl: a, viewName: o, condition: l, notification: u, interval: d } = t, t0;
|
|
1047
|
+
n[0] === r ? t0 = n[1] : (t0 = () => F.isEnabled(r), n[0] = r, n[1] = t0);
|
|
1048
|
+
let [f, p] = c(t0), m = s(r), t1, h;
|
|
1049
|
+
n[2] === r ? (t1 = n[3], h = n[4]) : (t1 = () => {
|
|
1050
|
+
m.current = r;
|
|
1051
|
+
}, h = [r], n[2] = r, n[3] = t1, n[4] = h), i(t1, h);
|
|
1052
|
+
let t3, g;
|
|
1053
|
+
n[5] !== l || n[6] !== r ? (t3 = () => {
|
|
1054
|
+
F.isEnabled(r) && F.updateCondition(r, l);
|
|
1055
|
+
}, g = [r, l], n[5] = l, n[6] = r, n[7] = t3, n[8] = g) : (t3 = n[7], g = n[8]), i(t3, g);
|
|
1056
|
+
let t5, _;
|
|
1057
|
+
n[9] !== u || n[10] !== r ? (t5 = () => {
|
|
1058
|
+
F.isEnabled(r) && F.updateNotification(r, u);
|
|
1059
|
+
}, _ = [r, u], n[9] = u, n[10] = r, n[11] = t5, n[12] = _) : (t5 = n[11], _ = n[12]), i(t5, _);
|
|
1060
|
+
let t7, v;
|
|
1061
|
+
n[13] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => () => {
|
|
1062
|
+
let e = m.current;
|
|
1063
|
+
F.isEnabled(e) && F.disable(e);
|
|
1064
|
+
}, v = [], n[13] = t7, n[14] = v) : (t7 = n[13], v = n[14]), i(t7, v);
|
|
1065
|
+
let t9;
|
|
1066
|
+
n[15] !== l || n[16] !== a || n[17] !== d || n[18] !== u || n[19] !== r || n[20] !== o ? (t9 = () => {
|
|
1067
|
+
F.enable(r, a, o, l, u, d), p(!0);
|
|
1068
|
+
}, n[15] = l, n[16] = a, n[17] = d, n[18] = u, n[19] = r, n[20] = o, n[21] = t9) : t9 = n[21];
|
|
1069
|
+
let y = t9, t10;
|
|
1070
|
+
n[22] === r ? t10 = n[23] : (t10 = () => {
|
|
1071
|
+
F.disable(r), p(!1);
|
|
1072
|
+
}, n[22] = r, n[23] = t10);
|
|
1073
|
+
let b = t10, t11;
|
|
1074
|
+
n[24] !== b || n[25] !== y || n[26] !== f ? (t11 = () => {
|
|
1075
|
+
f ? b() : y();
|
|
1076
|
+
}, n[24] = b, n[25] = y, n[26] = f, n[27] = t11) : t11 = n[27];
|
|
1077
|
+
let x = t11, S;
|
|
1078
|
+
return n[28] !== b || n[29] !== y || n[30] !== f || n[31] !== x ? (S = {
|
|
1079
|
+
isEnabled: f,
|
|
1080
|
+
enable: y,
|
|
1081
|
+
disable: b,
|
|
1082
|
+
toggle: x
|
|
1083
|
+
}, n[28] = b, n[29] = y, n[30] = f, n[31] = x, n[32] = S) : S = n[32], S;
|
|
1084
|
+
}
|
|
1085
|
+
//#endregion
|
|
1086
|
+
export { T as ANONYMOUS_USER, DataMonitorService, w as FullscreenContext, FullscreenProvider, C as PromiseStatus, RefreshableRouteGuard, RouteGuard, E as SecurityContext, SecurityProvider, addFullscreenChangeListener, collectMethods, createExecuteApiHooks, createQueryApiHooks, P as dataMonitorEventBus, F as dataMonitorService, enterFullscreen, exitFullscreen, getFullscreenElement, isFullscreen, isValidateQuery, methodNameToHookName, removeFullscreenChangeListener, useCountQuery, useDataMonitor, useDataMonitorEventBus, useDebouncedCallback, useDebouncedExecutePromise, useDebouncedFetcher, useDebouncedFetcherQuery, useDebouncedQuery, useEventSubscription, useExecutePromise, useFetcher, useFetcherCountQuery, useFetcherListQuery, useFetcherListStreamQuery, useFetcherPagedQuery, useFetcherQuery, useFetcherSingleQuery, useForceUpdate, useFullscreen, useFullscreenContext, useImmerKeyStorage, useKeyStorage, useLatest, useListQuery, useListStreamQuery, useMounted, usePagedQuery, usePromiseState, useQuery, useQueryState, useRefs, useRequestId, useSecurity, useSecurityContext, useSingleQuery };
|
|
858
1087
|
|
|
859
1088
|
//# sourceMappingURL=index.es.js.map
|