kosmio 0.1.2 → 0.1.3
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/README.md +30 -0
- package/dist/OfflineSyncContext-DWQu0vg_.js +40 -0
- package/dist/app.js +68 -57
- package/dist/context.js +1 -1
- package/dist/core.js +30 -28
- package/dist/formRegistry-CjW2-z6G.js +3622 -0
- package/dist/index.js +136 -133
- package/dist/{localizedRouter-BjT5yIzl.js → localizedRouter-CNO61cBH.js} +1 -1
- package/dist/offlineWriteQueue-BIJHFYuO.js +352 -0
- package/dist/styles.css +1 -1
- package/dist/ui.js +52 -51
- package/package.json +1 -1
- package/types/app.d.ts +7 -1
- package/types/context.d.ts +3 -2
- package/types/core.d.ts +7 -3
- package/types/ui.d.ts +15 -1
- package/dist/OfflineSyncContext-CRwPM5kh.js +0 -34
- package/dist/formRegistry-C5VIE7xu.js +0 -3469
- package/dist/offlineWriteQueue-C31IjyB_.js +0 -275
package/dist/index.js
CHANGED
|
@@ -1,185 +1,188 @@
|
|
|
1
1
|
import { createKosmioApp as s } from "./app.js";
|
|
2
2
|
import { createAccessRule as r, createPermissionRules as o, createPermissionScope as i, createPermissionSystem as n, createPlanLimits as l, limitByPlan as u, mergePermissionRules as c } from "./permissions.js";
|
|
3
|
-
import { A as p, a as
|
|
4
|
-
import { A as
|
|
5
|
-
import { D as
|
|
6
|
-
import { N as
|
|
7
|
-
import { A as
|
|
8
|
-
import { D as
|
|
9
|
-
import { F as
|
|
10
|
-
import { K as
|
|
11
|
-
import { L as
|
|
12
|
-
import {
|
|
13
|
-
import { c as
|
|
14
|
-
import { c as
|
|
15
|
-
import { c as
|
|
3
|
+
import { A as p, a as f, b as T, B as y, c as S, d, C as b, e as E, f as g, g as A, h as C, i as O, j as F, k as R, E as h, l as v, m as P, n as x, F as L, o as I, p as _, q as k, r as B, s as D, G as Q, t as M, u as W, I as U, v as H, w as K, x as N, y as q, z as w, L as G, N as V, O as j, D as z, P as Y, H as J, R as X, S as Z, J as $, K as ee, M as ae, Q as se, T as te, U as re, V as oe, W as ie, X as ne, Y as le, Z as ue, _ as ce, $ as me, a0 as pe, a1 as fe, a2 as Te, a3 as ye, a4 as Se, a5 as de, a6 as be, a7 as Ee, a8 as ge, a9 as Ae, aa as Ce, ab as Oe, ac as Fe, ad as Re, ae as he, af as ve, ag as Pe, ah as xe, ai as Le, aj as Ie, ak as _e, al as ke, am as Be, an as De, ao as Qe, ap as Me } from "./formRegistry-CjW2-z6G.js";
|
|
4
|
+
import { A as Ue, D as He, a as Ke, c as Ne, b as qe, m as we } from "./systemBars-C3QiEL7z.js";
|
|
5
|
+
import { D as Ve, M as je, r as ze } from "./MobileRouteTransition-C16D4K5c.js";
|
|
6
|
+
import { N as Je } from "./NativeBackButtonHandler-CcLHewdm.js";
|
|
7
|
+
import { A as Ze, E as $e, a as ea, F as aa, b as sa, c as ta, d as ra, e as oa, f as ia, g as na, i as la, k as ua, h as ca, m as ma, j as pa, l as fa, r as Ta, t as ya, n as Sa, o as da } from "./localizedRouter-CNO61cBH.js";
|
|
8
|
+
import { D as Ea, O as ga, u as Aa } from "./OfflineSyncContext-DWQu0vg_.js";
|
|
9
|
+
import { F as Oa, a as Fa, P as Ra, V as ha, c as va, u as Pa, b as xa, d as La, e as Ia } from "./ViewportContext-z-ZwlTIZ.js";
|
|
10
|
+
import { K as ka, a as Ba, c as Da, b as Qa, r as Ma } from "./KosmioThemeProvider-DzH5uTqT.js";
|
|
11
|
+
import { L as Ua, c as Ha, d as Ka, u as Na, a as qa, b as wa } from "./LanguageContext-DlN7MgUs.js";
|
|
12
|
+
import { O as Va, c as ja, e as za, g as Ya, a as Ja, i as Xa, b as Za, d as $a, f as es, p as as, r as ss, h as ts, s as rs, j as os, k as is } from "./offlineWriteQueue-BIJHFYuO.js";
|
|
13
|
+
import { c as ls, a as us, b as cs, g as ms, i as ps, d as fs, m as Ts, n as ys, p as Ss, r as ds, s as bs, v as Es } from "./shortcuts-n31uRPcv.js";
|
|
14
|
+
import { c as As, q as Cs } from "./queryClient-ZtNrT-lA.js";
|
|
15
|
+
import { c as Fs } from "./classNames-CcykAxZN.js";
|
|
16
16
|
export {
|
|
17
17
|
p as ActionButton,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
f as ActionsForm,
|
|
19
|
+
Ze as ApiClient,
|
|
20
|
+
Ue as AppUrlListener,
|
|
21
|
+
T as AppearChildren,
|
|
22
22
|
y as Backdrop,
|
|
23
23
|
S as BorderStyle,
|
|
24
24
|
d as Button,
|
|
25
25
|
b as Card,
|
|
26
26
|
E as Checkbox,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
g as Clickable,
|
|
28
|
+
A as CollapsibleBox,
|
|
29
29
|
C as CollapsibleCard,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
O as ColorTag,
|
|
31
|
+
F as Container,
|
|
32
32
|
R as ContainerStyle,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
Ve as DEFAULT_MOBILE_ROUTE_TRANSITION_STATE_KEY,
|
|
34
|
+
Ea as DEFAULT_OFFLINE_SYNC_STATE,
|
|
35
35
|
He as DEFAULT_THEME_NAVIGATION_BAR_COLORS,
|
|
36
36
|
Ke as DEFAULT_THEME_STATUS_BAR_COLORS,
|
|
37
37
|
h as EmptyCell,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
$e as Entity,
|
|
39
|
+
ea as EntityModelFactory,
|
|
40
40
|
v as EntityTable,
|
|
41
41
|
P as EnumOption,
|
|
42
42
|
x as EnumSelector,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
aa as Field,
|
|
44
|
+
sa as FieldTypes,
|
|
45
45
|
L as FloatingActionButton,
|
|
46
|
-
|
|
46
|
+
Oa as FloatingActionsProvider,
|
|
47
47
|
I as FloatingRowMenu,
|
|
48
48
|
_ as FormCheckbox,
|
|
49
49
|
k as FormInput,
|
|
50
50
|
B as FormSelect,
|
|
51
51
|
Fa as FormStateProvider,
|
|
52
52
|
D as FullSearchBar,
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
Q as GLOBAL_TABLE_SEARCH_SCOPE,
|
|
54
|
+
M as GeneratorInput,
|
|
55
55
|
W as Grid,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
U as Icon,
|
|
57
|
+
H as IconChevron,
|
|
58
|
+
K as IconRegistryIcon,
|
|
59
|
+
N as IconRegistryProvider,
|
|
60
60
|
q as IconTextCell,
|
|
61
61
|
w as Input,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
ka as KOSMIO_DEFAULT_THEME,
|
|
63
|
+
Ba as KosmioThemeProvider,
|
|
64
|
+
Ua as LanguageProvider,
|
|
65
65
|
G as Loader,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
je as MobileRouteTransition,
|
|
67
|
+
Je as NativeBackButtonHandler,
|
|
68
68
|
V as NavItem,
|
|
69
|
-
|
|
69
|
+
Va as OfflineQueueScopeUnavailableError,
|
|
70
|
+
ga as OfflineSyncProvider,
|
|
70
71
|
j as Overlay,
|
|
71
72
|
z as OverlayDialog,
|
|
72
73
|
Y as Page,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
X as
|
|
76
|
-
Z as
|
|
77
|
-
$ as
|
|
78
|
-
ee as
|
|
79
|
-
ae as
|
|
80
|
-
se as
|
|
81
|
-
te as
|
|
82
|
-
re as
|
|
83
|
-
oe as
|
|
84
|
-
ie as
|
|
85
|
-
ne as
|
|
86
|
-
le as
|
|
87
|
-
ue as
|
|
88
|
-
ce as
|
|
89
|
-
me as
|
|
90
|
-
|
|
91
|
-
|
|
74
|
+
J as PageContent,
|
|
75
|
+
Ra as PopupProvider,
|
|
76
|
+
X as ResponsiveTable,
|
|
77
|
+
Z as Searchbar,
|
|
78
|
+
$ as Select,
|
|
79
|
+
ee as SelectionButton,
|
|
80
|
+
ae as Sheet,
|
|
81
|
+
se as SidebarNav,
|
|
82
|
+
te as Table,
|
|
83
|
+
re as TableBody,
|
|
84
|
+
oe as TableCRUD,
|
|
85
|
+
ie as TableHead,
|
|
86
|
+
ne as TableRow,
|
|
87
|
+
le as TableSearchProvider,
|
|
88
|
+
ue as Tag,
|
|
89
|
+
ce as Text,
|
|
90
|
+
me as TextCell,
|
|
91
|
+
pe as TypoStyle,
|
|
92
|
+
ha as ViewportProvider,
|
|
93
|
+
fe as WriteEntityForm,
|
|
92
94
|
Te as buildActionsForm,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
ye as buildCreateFormDefaults,
|
|
96
|
+
ta as buildRoutePath,
|
|
97
|
+
ls as clamp,
|
|
98
|
+
ja as configureOfflineWriteQueue,
|
|
97
99
|
r as createAccessRule,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
Se as createActionsFormPayload,
|
|
101
|
+
de as createContainer,
|
|
102
|
+
be as createContainers,
|
|
103
|
+
ra as createEntityModels,
|
|
104
|
+
oa as createEntityResource,
|
|
105
|
+
ia as createEnumType,
|
|
106
|
+
va as createFormLauncher,
|
|
107
|
+
Ee as createFormRegistry,
|
|
106
108
|
Ha as createI18n,
|
|
107
|
-
|
|
109
|
+
ge as createIconComponent,
|
|
108
110
|
s as createKosmioApp,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
As as createKosmioQueryClient,
|
|
112
|
+
Da as createKosmioTheme,
|
|
113
|
+
na as createLocalizedRouter,
|
|
112
114
|
o as createPermissionRules,
|
|
113
115
|
i as createPermissionScope,
|
|
114
116
|
n as createPermissionSystem,
|
|
115
117
|
l as createPlanLimits,
|
|
116
118
|
Ne as createPlatformRuntime,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
us as createShortcutMatcher,
|
|
120
|
+
cs as createStaggerDelay,
|
|
121
|
+
qe as createSystemBarsController,
|
|
120
122
|
Ae as createTextStyle,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
Qa as createThemeStyle,
|
|
124
|
+
Ce as createTypo,
|
|
125
|
+
Oe as createTypos,
|
|
126
|
+
Fs as cx,
|
|
125
127
|
Fe as defineActionForm,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
Re as defineForm,
|
|
129
|
+
he as defineFormGroup,
|
|
128
130
|
Ka as detectInitialLanguage,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
131
|
+
za as enqueueOfflineWrite,
|
|
132
|
+
Ya as getOfflineWriteQueueScopeKey,
|
|
133
|
+
Ja as getOfflineWriteQueueState,
|
|
134
|
+
ms as getRevealStyle,
|
|
135
|
+
ps as isEditableTarget,
|
|
136
|
+
la as isEnumType,
|
|
137
|
+
Xa as isOfflineQueueCanceledResult,
|
|
138
|
+
Za as isOfflineQueueHandledResult,
|
|
139
|
+
$a as isOfflineQueueQueuedResult,
|
|
140
|
+
es as isQueueableWriteRequest,
|
|
141
|
+
fs as isTypingTarget,
|
|
142
|
+
ua as keysToCamel,
|
|
143
|
+
ca as keysToSnake,
|
|
142
144
|
u as limitByPlan,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
ma as makeCrudHooks,
|
|
146
|
+
pa as makeMutationHook,
|
|
147
|
+
fa as makeQueryHook,
|
|
148
|
+
we as mapAppUrlToRoute,
|
|
147
149
|
c as mergePermissionRules,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
Ts as motion,
|
|
151
|
+
ve as normalizeEntityForm,
|
|
152
|
+
ys as normalizeShortcutKey,
|
|
153
|
+
Ss as parseShortcutKeys,
|
|
154
|
+
as as pauseOfflineWriteQueueSync,
|
|
155
|
+
Cs as queryClient,
|
|
156
|
+
ss as registerOfflineWriteClient,
|
|
157
|
+
ts as requestOfflineWriteQueueSync,
|
|
158
|
+
Pe as resolveActionsFormActions,
|
|
159
|
+
ze as resolveMobileRouteTransition,
|
|
157
160
|
Ma as resolveThemeMode,
|
|
158
161
|
Ta as resolveTypeDescriptor,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
162
|
+
ds as rowAppearStyle,
|
|
163
|
+
bs as shortcutMatches,
|
|
164
|
+
rs as shouldQueueOfflineWrite,
|
|
165
|
+
os as startOfflineWriteQueueSync,
|
|
166
|
+
is as subscribeOfflineWriteQueue,
|
|
167
|
+
ya as toCamel,
|
|
168
|
+
Sa as toPascalCase,
|
|
169
|
+
da as toSnake,
|
|
170
|
+
xe as useDebounce,
|
|
171
|
+
Le as useEntityTableActions,
|
|
169
172
|
Na as useEnumLabel,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
qa as useEnumOptions,
|
|
174
|
+
Pa as useFloatingActions,
|
|
175
|
+
Ie as useFormDraft,
|
|
176
|
+
xa as useFormState,
|
|
177
|
+
_e as useIconRegistry,
|
|
178
|
+
wa as useLanguage,
|
|
176
179
|
Aa as useOfflineSync,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
ke as useOverlayDismiss,
|
|
181
|
+
La as usePopup,
|
|
182
|
+
Be as useSheetDragDismiss,
|
|
183
|
+
De as useTableSearch,
|
|
184
|
+
Qe as useTableSelection,
|
|
182
185
|
Me as useTableSorting,
|
|
183
|
-
|
|
184
|
-
|
|
186
|
+
Ia as useViewport,
|
|
187
|
+
Es as variants
|
|
185
188
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useQueryClient as ce, useMutation as de, useQuery as fe } from "@tanstack/react-query";
|
|
2
|
-
import { b as pe, r as me, f as ye, e as v, s as he } from "./offlineWriteQueue-
|
|
2
|
+
import { b as pe, r as me, f as ye, e as v, s as he } from "./offlineWriteQueue-BIJHFYuO.js";
|
|
3
3
|
import be from "axios";
|
|
4
4
|
function W(e, t, r) {
|
|
5
5
|
return function(n, a, p) {
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
let O = "kosmio:offline-write-queue:v1";
|
|
2
|
+
const E = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
3
|
+
let U = !1, p = null, A = !1, v = !1, d = !1, y = null, o = 0, h = null, m = 1500, R = null, b = null, w = null;
|
|
4
|
+
class S extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Offline write queue scope is unavailable."), this.name = "OfflineQueueScopeUnavailableError", this.code = "KOSMIO_OFFLINE_QUEUE_SCOPE_UNAVAILABLE";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function H() {
|
|
10
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
11
|
+
}
|
|
12
|
+
function $() {
|
|
13
|
+
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
14
|
+
}
|
|
15
|
+
function L(e) {
|
|
16
|
+
return encodeURIComponent(String(e ?? "").trim() || "default");
|
|
17
|
+
}
|
|
18
|
+
function C(e) {
|
|
19
|
+
return String(e ?? "").trim().toUpperCase();
|
|
20
|
+
}
|
|
21
|
+
function j(e) {
|
|
22
|
+
if (!e) return;
|
|
23
|
+
const t = typeof e.toJSON == "function" ? e.toJSON() : e;
|
|
24
|
+
if (!t || typeof t != "object") return;
|
|
25
|
+
const n = {};
|
|
26
|
+
for (const [r, i] of Object.entries(t))
|
|
27
|
+
(i == null || ["string", "number", "boolean"].includes(typeof i)) && (n[r] = i);
|
|
28
|
+
return Object.keys(n).length ? n : void 0;
|
|
29
|
+
}
|
|
30
|
+
function z(e = {}) {
|
|
31
|
+
const t = {}, n = j(e.headers);
|
|
32
|
+
n && (t.headers = n);
|
|
33
|
+
for (const r of ["timeout", "withCredentials", "responseType", "skipAuthRefresh"])
|
|
34
|
+
e[r] !== void 0 && (t[r] = e[r]);
|
|
35
|
+
return t;
|
|
36
|
+
}
|
|
37
|
+
function F(e) {
|
|
38
|
+
return ["POST", "PUT", "PATCH"].includes(C(e));
|
|
39
|
+
}
|
|
40
|
+
function J(e) {
|
|
41
|
+
return e?.offlineQueue === !1;
|
|
42
|
+
}
|
|
43
|
+
function k(e) {
|
|
44
|
+
return e ? e.response ? !1 : typeof navigator < "u" && navigator.onLine === !1 ? !0 : ["ERR_NETWORK", "ECONNABORTED"].includes(String(e.code ?? "")) : !1;
|
|
45
|
+
}
|
|
46
|
+
function V(e) {
|
|
47
|
+
return D.has(Number(e));
|
|
48
|
+
}
|
|
49
|
+
function Y(e, t) {
|
|
50
|
+
return `${O}:${L(e)}:${L(t)}`;
|
|
51
|
+
}
|
|
52
|
+
function M(e) {
|
|
53
|
+
const t = N.get(e);
|
|
54
|
+
return Array.isArray(t) ? t : [];
|
|
55
|
+
}
|
|
56
|
+
function G(e, t) {
|
|
57
|
+
N.set(e, Array.isArray(t) ? t : []);
|
|
58
|
+
}
|
|
59
|
+
function q(e) {
|
|
60
|
+
if (typeof window > "u") return M(e);
|
|
61
|
+
try {
|
|
62
|
+
const t = window.localStorage.getItem(e);
|
|
63
|
+
if (!t) return [];
|
|
64
|
+
const n = JSON.parse(t);
|
|
65
|
+
return Array.isArray(n) ? n : [];
|
|
66
|
+
} catch {
|
|
67
|
+
return M(e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function l(e, t) {
|
|
71
|
+
const n = Array.isArray(t) ? t : [];
|
|
72
|
+
if (G(e, n), c(), typeof window > "u") return !0;
|
|
73
|
+
try {
|
|
74
|
+
return window.localStorage.setItem(e, JSON.stringify(n)), !0;
|
|
75
|
+
} catch {
|
|
76
|
+
return !1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function X(e) {
|
|
80
|
+
const t = String(e?.url ?? ""), n = C(e?.method);
|
|
81
|
+
if (!["POST", "PUT", "PATCH"].includes(n)) return null;
|
|
82
|
+
const r = t.match(/^(.*)\/(archive|unarchive)\/?$/i);
|
|
83
|
+
return r ? { archiveResourceKey: r[1], archiveAction: r[2].toLowerCase() } : null;
|
|
84
|
+
}
|
|
85
|
+
function Z({ clientKey: e, scopeKey: t, requestConfig: n, reason: r }) {
|
|
86
|
+
const i = X(n);
|
|
87
|
+
return {
|
|
88
|
+
id: $(),
|
|
89
|
+
clientKey: e,
|
|
90
|
+
scopeKey: t,
|
|
91
|
+
createdAt: H(),
|
|
92
|
+
retryCount: 0,
|
|
93
|
+
reason: r,
|
|
94
|
+
request: {
|
|
95
|
+
method: C(n.method),
|
|
96
|
+
url: n.url,
|
|
97
|
+
data: n.data,
|
|
98
|
+
config: z(n)
|
|
99
|
+
},
|
|
100
|
+
archiveAction: i?.archiveAction ?? null,
|
|
101
|
+
archiveResourceKey: i?.archiveResourceKey ?? null
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function ee(e, t) {
|
|
105
|
+
const n = Array.isArray(e) ? [...e] : [];
|
|
106
|
+
if (!t?.archiveResourceKey || !t?.archiveAction)
|
|
107
|
+
return n.push(t), { queue: n, queued: !0, canceled: !1 };
|
|
108
|
+
const i = n.filter((a) => a?.archiveResourceKey === t.archiveResourceKey).some(
|
|
109
|
+
(a) => a?.archiveAction && a.archiveAction !== t.archiveAction
|
|
110
|
+
), u = n.filter((a) => a?.archiveResourceKey !== t.archiveResourceKey);
|
|
111
|
+
return i ? { queue: u, queued: !1, canceled: !0 } : (u.push(t), { queue: u, queued: !0, canceled: !1 });
|
|
112
|
+
}
|
|
113
|
+
async function P() {
|
|
114
|
+
if (typeof R != "function")
|
|
115
|
+
throw new S();
|
|
116
|
+
try {
|
|
117
|
+
const e = await R();
|
|
118
|
+
if (typeof e != "string" || !e.trim())
|
|
119
|
+
throw new S();
|
|
120
|
+
return e.trim();
|
|
121
|
+
} catch (e) {
|
|
122
|
+
throw e instanceof S ? e : new S();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function K(e) {
|
|
126
|
+
return e?.queueKey ?? e?.ax?.defaults?.baseURL ?? "default";
|
|
127
|
+
}
|
|
128
|
+
function I(e, t) {
|
|
129
|
+
return Y(K(e), t);
|
|
130
|
+
}
|
|
131
|
+
function te(e) {
|
|
132
|
+
if (!e) return 0;
|
|
133
|
+
let t = 0;
|
|
134
|
+
for (const n of E.values())
|
|
135
|
+
t += q(I(n, e)).length;
|
|
136
|
+
return t;
|
|
137
|
+
}
|
|
138
|
+
function W() {
|
|
139
|
+
return typeof navigator > "u" ? !0 : navigator.onLine !== !1;
|
|
140
|
+
}
|
|
141
|
+
function c() {
|
|
142
|
+
for (const e of Q)
|
|
143
|
+
try {
|
|
144
|
+
e();
|
|
145
|
+
} catch {
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function ne(e) {
|
|
149
|
+
if (!e)
|
|
150
|
+
return {
|
|
151
|
+
isOnline: W(),
|
|
152
|
+
isSyncing: !1,
|
|
153
|
+
pendingSyncCount: 0,
|
|
154
|
+
hasPendingSync: !1
|
|
155
|
+
};
|
|
156
|
+
const t = String(e), n = te(t), r = {
|
|
157
|
+
isOnline: W(),
|
|
158
|
+
isSyncing: v,
|
|
159
|
+
pendingSyncCount: n,
|
|
160
|
+
hasPendingSync: n > 0
|
|
161
|
+
}, i = T.get(t);
|
|
162
|
+
return i && i.isOnline === r.isOnline && i.isSyncing === r.isSyncing && i.pendingSyncCount === r.pendingSyncCount && i.hasPendingSync === r.hasPendingSync ? i : (T.set(t, r), r);
|
|
163
|
+
}
|
|
164
|
+
function re() {
|
|
165
|
+
if (h) return;
|
|
166
|
+
h = setTimeout(() => {
|
|
167
|
+
h = null, s().catch(() => {
|
|
168
|
+
});
|
|
169
|
+
}, m), m = Math.min(m * 2, 6e4), c();
|
|
170
|
+
}
|
|
171
|
+
function ie() {
|
|
172
|
+
m = 1500, h && (clearTimeout(h), h = null);
|
|
173
|
+
}
|
|
174
|
+
async function ue(e, t) {
|
|
175
|
+
const n = I(e, t), r = q(n);
|
|
176
|
+
if (!r.length) return { applied: 0, retryScheduled: !1 };
|
|
177
|
+
let i = 0;
|
|
178
|
+
const u = [...r];
|
|
179
|
+
for (; u.length > 0; ) {
|
|
180
|
+
const a = await x(t);
|
|
181
|
+
if (o > 0 || !a)
|
|
182
|
+
return { applied: i, retryScheduled: !1, interrupted: !0 };
|
|
183
|
+
const f = u[0];
|
|
184
|
+
try {
|
|
185
|
+
if (!_(f.request)) {
|
|
186
|
+
u.shift(), l(n, u);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
await e.ax.request({
|
|
190
|
+
...f.request.config,
|
|
191
|
+
method: f.request.method,
|
|
192
|
+
url: f.request.url,
|
|
193
|
+
data: f.request.data
|
|
194
|
+
}), u.shift(), i += 1, l(n, u);
|
|
195
|
+
} catch (g) {
|
|
196
|
+
if (k(g) || V(g?.response?.status))
|
|
197
|
+
return f.retryCount = (f.retryCount ?? 0) + 1, l(n, u), re(), { applied: i, retryScheduled: !0 };
|
|
198
|
+
u.shift(), l(n, u);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return l(n, u), { applied: i, retryScheduled: !1 };
|
|
202
|
+
}
|
|
203
|
+
async function x(e) {
|
|
204
|
+
if (o > 0) return !1;
|
|
205
|
+
try {
|
|
206
|
+
const t = await P();
|
|
207
|
+
return o === 0 && t === e;
|
|
208
|
+
} catch {
|
|
209
|
+
return !1;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async function oe() {
|
|
213
|
+
let e;
|
|
214
|
+
try {
|
|
215
|
+
e = await P();
|
|
216
|
+
} catch (n) {
|
|
217
|
+
if (n instanceof S) return 0;
|
|
218
|
+
throw n;
|
|
219
|
+
}
|
|
220
|
+
let t = 0;
|
|
221
|
+
for (const n of E.values()) {
|
|
222
|
+
const r = await x(e);
|
|
223
|
+
if (o > 0 || !r) break;
|
|
224
|
+
const i = await ue(n, e);
|
|
225
|
+
if (t += i.applied, i.retryScheduled || i.interrupted) break;
|
|
226
|
+
}
|
|
227
|
+
return t > 0 && typeof b == "function" && b(), c(), t;
|
|
228
|
+
}
|
|
229
|
+
function ae() {
|
|
230
|
+
return o > 0 ? (d = !0, Promise.resolve()) : v ? (d = !0, y ?? Promise.resolve()) : (v = !0, c(), y = (async () => {
|
|
231
|
+
try {
|
|
232
|
+
do {
|
|
233
|
+
if (d = !1, o > 0) break;
|
|
234
|
+
await oe() > 0 && ie();
|
|
235
|
+
} while (d && o === 0);
|
|
236
|
+
} finally {
|
|
237
|
+
v = !1, y = null, c();
|
|
238
|
+
}
|
|
239
|
+
})(), y);
|
|
240
|
+
}
|
|
241
|
+
function ce() {
|
|
242
|
+
c(), s().catch(() => {
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function fe() {
|
|
246
|
+
c();
|
|
247
|
+
}
|
|
248
|
+
function se() {
|
|
249
|
+
typeof document < "u" && document.visibilityState === "visible" && s().catch(() => {
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function le(e) {
|
|
253
|
+
e?.isActive && s().catch(() => {
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function de(e = {}) {
|
|
257
|
+
if (A) {
|
|
258
|
+
if (e.storagePrefix !== void 0 && e.storagePrefix !== O)
|
|
259
|
+
throw new Error("Offline queue storagePrefix cannot change after sync starts.");
|
|
260
|
+
if (e.appStateAdapter !== void 0 && e.appStateAdapter !== w)
|
|
261
|
+
throw new Error("Offline queue appStateAdapter cannot change after sync starts.");
|
|
262
|
+
}
|
|
263
|
+
typeof e.storagePrefix == "string" && e.storagePrefix.trim() && (O = e.storagePrefix.trim()), typeof e.resolveScopeKey == "function" && (R = e.resolveScopeKey), typeof e.invalidateQueries == "function" && (b = e.invalidateQueries), e.appStateAdapter !== void 0 && (w = e.appStateAdapter);
|
|
264
|
+
}
|
|
265
|
+
function ye(e) {
|
|
266
|
+
if (!e) return e;
|
|
267
|
+
const t = K(e);
|
|
268
|
+
return e.queueKey = t, E.set(t, e), c(), e;
|
|
269
|
+
}
|
|
270
|
+
function he(e) {
|
|
271
|
+
return ["queued", "canceled"].includes(String(e?.offlineQueueStatus ?? ""));
|
|
272
|
+
}
|
|
273
|
+
function pe(e) {
|
|
274
|
+
return String(e?.offlineQueueStatus ?? "") === "queued";
|
|
275
|
+
}
|
|
276
|
+
function Se(e) {
|
|
277
|
+
return String(e?.offlineQueueStatus ?? "") === "canceled";
|
|
278
|
+
}
|
|
279
|
+
function _(e) {
|
|
280
|
+
return F(e?.method) && !J(e);
|
|
281
|
+
}
|
|
282
|
+
function we({ userId: e, tenantId: t } = {}) {
|
|
283
|
+
const n = String(e ?? "").trim() || "anonymous", r = String(t ?? "").trim() || "no-tenant";
|
|
284
|
+
return `${n}:${r}`;
|
|
285
|
+
}
|
|
286
|
+
function ge(e) {
|
|
287
|
+
return ne(e);
|
|
288
|
+
}
|
|
289
|
+
function ve(e) {
|
|
290
|
+
return typeof e != "function" ? () => {
|
|
291
|
+
} : (Q.add(e), () => Q.delete(e));
|
|
292
|
+
}
|
|
293
|
+
async function me(e, t, n = "offline") {
|
|
294
|
+
if (o > 0)
|
|
295
|
+
throw new Error("Offline write queue is paused during an identity scope change.");
|
|
296
|
+
const r = await P();
|
|
297
|
+
if (o > 0)
|
|
298
|
+
throw new Error("Offline write queue is paused during an identity scope change.");
|
|
299
|
+
const i = I(e, r), u = q(i), a = Z({ clientKey: K(e), scopeKey: r, requestConfig: t, reason: n }), { queue: f, queued: g, canceled: B } = ee(u, a);
|
|
300
|
+
return l(i, f), s().catch(() => {
|
|
301
|
+
}), B ? { offlineQueueStatus: "canceled", offlineQueueReason: "archive_canceled", offlineQueueScope: r } : g ? { offlineQueueStatus: "queued", offlineQueueId: a.id, offlineQueueScope: r } : { offlineQueueStatus: "canceled", offlineQueueReason: "deduped", offlineQueueScope: r };
|
|
302
|
+
}
|
|
303
|
+
function Oe(e, t) {
|
|
304
|
+
return _(t) ? typeof navigator < "u" && navigator.onLine === !1 ? !0 : k(e) : !1;
|
|
305
|
+
}
|
|
306
|
+
function s() {
|
|
307
|
+
return d = !0, ae();
|
|
308
|
+
}
|
|
309
|
+
async function Qe() {
|
|
310
|
+
o += 1, c();
|
|
311
|
+
try {
|
|
312
|
+
y && await y;
|
|
313
|
+
} catch (t) {
|
|
314
|
+
throw o = Math.max(0, o - 1), c(), t;
|
|
315
|
+
}
|
|
316
|
+
let e = !1;
|
|
317
|
+
return () => {
|
|
318
|
+
e || (e = !0, o = Math.max(0, o - 1), c(), o === 0 && d && s().catch(() => {
|
|
319
|
+
}));
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
async function Ae() {
|
|
323
|
+
typeof window < "u" && !U && (U = !0, A = !0, window.addEventListener("online", ce), window.addEventListener("offline", fe), typeof document < "u" && document.addEventListener("visibilitychange", se));
|
|
324
|
+
let e = null;
|
|
325
|
+
try {
|
|
326
|
+
w && typeof w.addListener == "function" && !p && (A = !0, p = Promise.resolve(
|
|
327
|
+
w.addListener("appStateChange", le)
|
|
328
|
+
).catch((t) => {
|
|
329
|
+
throw p = null, t;
|
|
330
|
+
})), p && await p;
|
|
331
|
+
} catch (t) {
|
|
332
|
+
e = t;
|
|
333
|
+
}
|
|
334
|
+
if (await s(), e) throw e;
|
|
335
|
+
}
|
|
336
|
+
export {
|
|
337
|
+
S as O,
|
|
338
|
+
ge as a,
|
|
339
|
+
he as b,
|
|
340
|
+
de as c,
|
|
341
|
+
pe as d,
|
|
342
|
+
me as e,
|
|
343
|
+
_ as f,
|
|
344
|
+
we as g,
|
|
345
|
+
s as h,
|
|
346
|
+
Se as i,
|
|
347
|
+
Ae as j,
|
|
348
|
+
ve as k,
|
|
349
|
+
Qe as p,
|
|
350
|
+
ye as r,
|
|
351
|
+
Oe as s
|
|
352
|
+
};
|