tempest-react-sdk 0.80.0 → 0.82.0
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 +40 -10
- package/bin/create-tempest-app.e2e.test.mjs +31 -0
- package/bin/create-tempest-app.mjs +11 -1
- package/bin/lib/component/generate.test.mjs +13 -1
- package/bin/lib/doctor/doctor.e2e.test.mjs +29 -0
- package/bin/lib/doctor/vitest.mjs +120 -0
- package/bin/lib/doctor/vitest.test.mjs +139 -0
- package/bin/lib/fs/contain.mjs +7 -0
- package/bin/lib/openapi/escape.mjs +68 -4
- package/bin/lib/openapi/generate.hostile.test.mjs +150 -1
- package/bin/lib/openapi/generate.mjs +78 -13
- package/bin/lib/openapi/generate.test.mjs +13 -1
- package/bin/lib/openapi/pattern-risk.mjs +134 -0
- package/bin/lib/openapi/pattern-risk.test.mjs +45 -0
- package/bin/tempest-gen.test.mjs +100 -0
- package/bin/tempest.mjs +24 -8
- package/dist/access/use-can.cjs +1 -1
- package/dist/access/use-can.cjs.map +1 -1
- package/dist/access/use-can.js +25 -28
- package/dist/access/use-can.js.map +1 -1
- package/dist/auth/create-tempest-auth.cjs +1 -1
- package/dist/auth/create-tempest-auth.cjs.map +1 -1
- package/dist/auth/create-tempest-auth.js +234 -122
- package/dist/auth/create-tempest-auth.js.map +1 -1
- package/dist/auth/session-identity.cjs +2 -0
- package/dist/auth/session-identity.cjs.map +1 -0
- package/dist/auth/session-identity.js +12 -0
- package/dist/auth/session-identity.js.map +1 -0
- package/dist/br/boleto.cjs +1 -1
- package/dist/br/boleto.cjs.map +1 -1
- package/dist/br/boleto.js +2 -1
- package/dist/br/boleto.js.map +1 -1
- package/dist/br.d.ts +22 -3
- package/dist/components/AuthForm/AuthFieldControl.cjs +2 -0
- package/dist/components/AuthForm/AuthFieldControl.cjs.map +1 -0
- package/dist/components/AuthForm/AuthFieldControl.js +85 -0
- package/dist/components/AuthForm/AuthFieldControl.js.map +1 -0
- package/dist/components/AuthForm/AuthForm.cjs +2 -0
- package/dist/components/AuthForm/AuthForm.cjs.map +1 -0
- package/dist/components/AuthForm/AuthForm.js +83 -0
- package/dist/components/AuthForm/AuthForm.js.map +1 -0
- package/dist/components/AuthForm/AuthForm.module.cjs +3 -0
- package/dist/components/AuthForm/AuthForm.module.cjs.map +1 -0
- package/dist/components/AuthForm/AuthForm.module.js +14 -0
- package/dist/components/AuthForm/AuthForm.module.js.map +1 -0
- package/dist/components/AuthForm/AuthLinks.cjs +2 -0
- package/dist/components/AuthForm/AuthLinks.cjs.map +1 -0
- package/dist/components/AuthForm/AuthLinks.js +32 -0
- package/dist/components/AuthForm/AuthLinks.js.map +1 -0
- package/dist/components/AuthForm/ForgotPasswordForm.cjs +2 -0
- package/dist/components/AuthForm/ForgotPasswordForm.cjs.map +1 -0
- package/dist/components/AuthForm/ForgotPasswordForm.js +32 -0
- package/dist/components/AuthForm/ForgotPasswordForm.js.map +1 -0
- package/dist/components/AuthForm/LoginForm.cjs +2 -0
- package/dist/components/AuthForm/LoginForm.cjs.map +1 -0
- package/dist/components/AuthForm/LoginForm.js +39 -0
- package/dist/components/AuthForm/LoginForm.js.map +1 -0
- package/dist/components/AuthForm/ResetPasswordForm.cjs +2 -0
- package/dist/components/AuthForm/ResetPasswordForm.cjs.map +1 -0
- package/dist/components/AuthForm/ResetPasswordForm.js +39 -0
- package/dist/components/AuthForm/ResetPasswordForm.js.map +1 -0
- package/dist/components/AuthForm/SignUpForm.cjs +2 -0
- package/dist/components/AuthForm/SignUpForm.cjs.map +1 -0
- package/dist/components/AuthForm/SignUpForm.js +32 -0
- package/dist/components/AuthForm/SignUpForm.js.map +1 -0
- package/dist/components/AuthForm/auth-defaults.cjs +2 -0
- package/dist/components/AuthForm/auth-defaults.cjs.map +1 -0
- package/dist/components/AuthForm/auth-defaults.js +54 -0
- package/dist/components/AuthForm/auth-defaults.js.map +1 -0
- package/dist/components/AuthForm/auth-schemas.cjs +2 -0
- package/dist/components/AuthForm/auth-schemas.cjs.map +1 -0
- package/dist/components/AuthForm/auth-schemas.js +26 -0
- package/dist/components/AuthForm/auth-schemas.js.map +1 -0
- package/dist/components/AuthPage/AuthPage.cjs +2 -0
- package/dist/components/AuthPage/AuthPage.cjs.map +1 -0
- package/dist/components/AuthPage/AuthPage.js +97 -0
- package/dist/components/AuthPage/AuthPage.js.map +1 -0
- package/dist/components/AuthPage/AuthPage.module.cjs +3 -0
- package/dist/components/AuthPage/AuthPage.module.cjs.map +1 -0
- package/dist/components/AuthPage/AuthPage.module.js +24 -0
- package/dist/components/AuthPage/AuthPage.module.js.map +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +22 -21
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js +41 -40
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Chat/ChatAttachments.cjs +1 -1
- package/dist/components/Chat/ChatAttachments.cjs.map +1 -1
- package/dist/components/Chat/ChatAttachments.js +38 -38
- package/dist/components/FilterBar/filter-apply.cjs +1 -1
- package/dist/components/FilterBar/filter-apply.cjs.map +1 -1
- package/dist/components/FilterBar/filter-apply.js +7 -7
- package/dist/components/Form/Form.cjs +1 -1
- package/dist/components/Form/Form.cjs.map +1 -1
- package/dist/components/Form/Form.js +30 -32
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Layout/Layout.cjs +1 -1
- package/dist/components/Layout/Layout.cjs.map +1 -1
- package/dist/components/Layout/Layout.js +25 -24
- package/dist/components/Layout/Layout.js.map +1 -1
- package/dist/components/Layout/gap.cjs +2 -0
- package/dist/components/Layout/gap.cjs.map +1 -0
- package/dist/components/Layout/gap.js +15 -0
- package/dist/components/Layout/gap.js.map +1 -0
- package/dist/components/NavigationMenu/NavigationMenu.cjs +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.js +71 -70
- package/dist/components/NavigationMenu/NavigationMenu.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.cjs.map +1 -1
- package/dist/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/components/Sidebar/SidebarEntry.cjs +1 -1
- package/dist/components/Sidebar/SidebarEntry.cjs.map +1 -1
- package/dist/components/Sidebar/SidebarEntry.js +30 -29
- package/dist/components/Sidebar/SidebarEntry.js.map +1 -1
- package/dist/data/create-data-provider.cjs +1 -1
- package/dist/data/create-data-provider.cjs.map +1 -1
- package/dist/data/create-data-provider.js +1 -2
- package/dist/data/create-data-provider.js.map +1 -1
- package/dist/forms/index.js +7 -7
- package/dist/forms/masked-inputs.cjs +1 -1
- package/dist/forms/masked-inputs.cjs.map +1 -1
- package/dist/forms/masked-inputs.js +15 -15
- package/dist/forms/validate-form.cjs +1 -1
- package/dist/forms/validate-form.cjs.map +1 -1
- package/dist/forms/validate-form.js +6 -1
- package/dist/forms/validate-form.js.map +1 -1
- package/dist/forms/zod-resolver.cjs +1 -1
- package/dist/forms/zod-resolver.cjs.map +1 -1
- package/dist/forms/zod-resolver.js +8 -3
- package/dist/forms/zod-resolver.js.map +1 -1
- package/dist/http/api-client.cjs +1 -1
- package/dist/http/api-client.cjs.map +1 -1
- package/dist/http/api-client.js +137 -116
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/credential-scope.cjs +1 -1
- package/dist/http/credential-scope.cjs.map +1 -1
- package/dist/http/credential-scope.js +33 -9
- package/dist/http/credential-scope.js.map +1 -1
- package/dist/http/presigned-post.cjs.map +1 -1
- package/dist/http/presigned-post.js.map +1 -1
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +140 -134
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/upload-with-progress.cjs +1 -1
- package/dist/http/upload-with-progress.cjs.map +1 -1
- package/dist/http/upload-with-progress.js +17 -17
- package/dist/http/upload-with-progress.js.map +1 -1
- package/dist/http/use-describe-api-error.cjs +1 -1
- package/dist/http/use-describe-api-error.cjs.map +1 -1
- package/dist/http/use-describe-api-error.js +9 -9
- package/dist/oauth/GoogleSignIn.cjs +1 -1
- package/dist/oauth/GoogleSignIn.cjs.map +1 -1
- package/dist/oauth/GoogleSignIn.js +5 -4
- package/dist/oauth/GoogleSignIn.js.map +1 -1
- package/dist/offline/create-offline-sync.cjs +1 -1
- package/dist/offline/create-offline-sync.cjs.map +1 -1
- package/dist/offline/create-offline-sync.js +108 -68
- package/dist/offline/create-offline-sync.js.map +1 -1
- package/dist/query/offline-persistence.cjs +1 -1
- package/dist/query/offline-persistence.cjs.map +1 -1
- package/dist/query/offline-persistence.js +54 -44
- package/dist/query/offline-persistence.js.map +1 -1
- package/dist/sse/create-event-stream.cjs +1 -1
- package/dist/sse/create-event-stream.cjs.map +1 -1
- package/dist/sse/create-event-stream.js +48 -41
- package/dist/sse/create-event-stream.js.map +1 -1
- package/dist/sse/ticket-event-stream.cjs +1 -1
- package/dist/sse/ticket-event-stream.cjs.map +1 -1
- package/dist/sse/ticket-event-stream.js +48 -19
- package/dist/sse/ticket-event-stream.js.map +1 -1
- package/dist/sse/use-event-stream.cjs +1 -1
- package/dist/sse/use-event-stream.cjs.map +1 -1
- package/dist/sse/use-event-stream.js +19 -14
- package/dist/sse/use-event-stream.js.map +1 -1
- package/dist/styles/AuthForm.css +2 -0
- package/dist/styles/AuthPage.css +2 -0
- package/dist/styles/component/AuthForm.css +9 -0
- package/dist/styles/component/AuthPage.css +29 -0
- package/dist/styles/forms.css +36 -0
- package/dist/styles/manifest.json +63 -0
- package/dist/styles.css +1 -1
- package/dist/sw/background-sync.cjs +1 -1
- package/dist/sw/background-sync.cjs.map +1 -1
- package/dist/sw/background-sync.js +132 -112
- package/dist/sw/background-sync.js.map +1 -1
- package/dist/sw/cache.cjs +1 -1
- package/dist/sw/cache.cjs.map +1 -1
- package/dist/sw/cache.js +36 -30
- package/dist/sw/cache.js.map +1 -1
- package/dist/sw/create-push-handler.cjs +1 -1
- package/dist/sw/create-push-handler.cjs.map +1 -1
- package/dist/sw/create-push-handler.js +20 -10
- package/dist/sw/create-push-handler.js.map +1 -1
- package/dist/sw.d.ts +93 -28
- package/dist/tabular/compact.cjs +1 -1
- package/dist/tabular/compact.cjs.map +1 -1
- package/dist/tabular/compact.js +35 -16
- package/dist/tabular/compact.js.map +1 -1
- package/dist/tabular/manifest.cjs +1 -1
- package/dist/tabular/manifest.cjs.map +1 -1
- package/dist/tabular/manifest.js +33 -15
- package/dist/tabular/manifest.js.map +1 -1
- package/dist/tabular.d.ts +11 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +1057 -83
- package/dist/tempest-react-sdk.js +373 -365
- package/dist/theme/initial-theme.cjs +4 -4
- package/dist/theme/initial-theme.cjs.map +1 -1
- package/dist/theme/initial-theme.js +8 -5
- package/dist/theme/initial-theme.js.map +1 -1
- package/dist/utils/compressed-storage.cjs +1 -1
- package/dist/utils/compressed-storage.cjs.map +1 -1
- package/dist/utils/compressed-storage.js +13 -7
- package/dist/utils/compressed-storage.js.map +1 -1
- package/dist/utils/format.cjs +1 -1
- package/dist/utils/format.cjs.map +1 -1
- package/dist/utils/format.js +25 -25
- package/dist/utils/numbers.cjs +1 -1
- package/dist/utils/numbers.cjs.map +1 -1
- package/dist/utils/numbers.js +7 -7
- package/dist/utils/objects.cjs +1 -1
- package/dist/utils/objects.cjs.map +1 -1
- package/dist/utils/objects.js +13 -7
- package/dist/utils/objects.js.map +1 -1
- package/dist/utils/safe-url.cjs +1 -1
- package/dist/utils/safe-url.cjs.map +1 -1
- package/dist/utils/safe-url.js +4 -1
- package/dist/utils/safe-url.js.map +1 -1
- package/dist/webrtc/peer-mesh.cjs +1 -1
- package/dist/webrtc/peer-mesh.cjs.map +1 -1
- package/dist/webrtc/peer-mesh.js +7 -1
- package/dist/webrtc/peer-mesh.js.map +1 -1
- package/dist/ws/create-web-socket.cjs +1 -1
- package/dist/ws/create-web-socket.cjs.map +1 -1
- package/dist/ws/create-web-socket.js +77 -61
- package/dist/ws/create-web-socket.js.map +1 -1
- package/dist/ws/use-web-socket.cjs +1 -1
- package/dist/ws/use-web-socket.cjs.map +1 -1
- package/dist/ws/use-web-socket.js +4 -3
- package/dist/ws/use-web-socket.js.map +1 -1
- package/package.json +1 -1
- package/template-pwa/src/pwa.tsx +42 -0
- package/template-pwa/src/sw.ts +15 -10
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { retry as
|
|
6
|
-
import {
|
|
1
|
+
import { TempestApiError as e, buildApiError as t, isApiError as n, isRetriableStatus as r } from "./errors.js";
|
|
2
|
+
import { bytesToBase64 as i } from "../utils/base64.js";
|
|
3
|
+
import { isTrustedCredentialTarget as a, reportSuppressedCredential as o, resolveRequestUrl as s } from "./credential-scope.js";
|
|
4
|
+
import { csrfHeaders as c } from "./csrf.js";
|
|
5
|
+
import { retry as l } from "./retry.js";
|
|
6
|
+
import { sessionIdentityOf as u } from "../auth/session-identity.js";
|
|
7
|
+
import { ownerFingerprint as d } from "../utils/owner-fingerprint.js";
|
|
7
8
|
import { generateIdempotencyKey as ee } from "./idempotency.js";
|
|
8
9
|
//#region src/http/resumable-upload.ts
|
|
9
|
-
var
|
|
10
|
+
var f = "1.0.0", p = 5242880, m = class extends Error {
|
|
10
11
|
reason;
|
|
11
12
|
constructor(e) {
|
|
12
13
|
super(e === "principal" ? "O usuário mudou durante o upload resumível." : "Os registros de upload resumível foram limpos durante o upload."), this.name = "ResumableUploadSupersededError", this.reason = e;
|
|
13
14
|
}
|
|
14
|
-
},
|
|
15
|
-
function
|
|
15
|
+
}, h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
function _(e) {
|
|
16
17
|
if (!e) return !1;
|
|
17
18
|
try {
|
|
18
19
|
let t = JSON.parse(e);
|
|
@@ -21,19 +22,19 @@ function h(e) {
|
|
|
21
22
|
return !1;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
25
|
+
function v(e) {
|
|
26
|
+
return i(new TextEncoder().encode(e));
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function te(e) {
|
|
28
29
|
if (!e) return null;
|
|
29
|
-
let t = Object.entries(e).map(([e, t]) => `${e} ${
|
|
30
|
+
let t = Object.entries(e).map(([e, t]) => `${e} ${v(t)}`);
|
|
30
31
|
return t.length > 0 ? t.join(",") : null;
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function y(e, t) {
|
|
33
34
|
let n = t, r = typeof n.name == "string" ? n.name : "blob", i = typeof n.lastModified == "number" ? n.lastModified : 0;
|
|
34
35
|
return `${e}|${r}|${t.size}|${t.type}|${i}`;
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function b(e = "tempest-upload:") {
|
|
37
38
|
function t() {
|
|
38
39
|
try {
|
|
39
40
|
return typeof localStorage > "u" ? null : localStorage;
|
|
@@ -58,45 +59,45 @@ function y(e = "tempest-upload:") {
|
|
|
58
59
|
t()?.removeItem(e + n);
|
|
59
60
|
},
|
|
60
61
|
clear() {
|
|
61
|
-
|
|
62
|
+
h.set(e, (h.get(e) ?? 0) + 1);
|
|
62
63
|
let n = t();
|
|
63
64
|
if (!n) return;
|
|
64
65
|
let r = [];
|
|
65
66
|
for (let t = 0; t < n.length; t += 1) {
|
|
66
67
|
let i = n.key(t);
|
|
67
|
-
i?.startsWith(e) &&
|
|
68
|
+
i?.startsWith(e) && _(n.getItem(i)) && r.push(i);
|
|
68
69
|
}
|
|
69
70
|
for (let e of r) n.removeItem(e);
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
|
-
return
|
|
73
|
+
return g.set(n, () => h.get(e) ?? 0), n;
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
-
return new Promise((
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
for (let [
|
|
79
|
-
if (
|
|
80
|
-
let
|
|
81
|
-
|
|
75
|
+
function x(t) {
|
|
76
|
+
return new Promise((n, r) => {
|
|
77
|
+
let i = new XMLHttpRequest();
|
|
78
|
+
i.open(t.method, t.url), i.withCredentials = t.withCredentials;
|
|
79
|
+
for (let [e, n] of Object.entries(t.headers)) i.setRequestHeader(e, n);
|
|
80
|
+
if (t.onProgress) {
|
|
81
|
+
let e = t.onProgress;
|
|
82
|
+
i.upload.onprogress = (t) => e(t.loaded);
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
status:
|
|
85
|
-
text:
|
|
86
|
-
header: (e) =>
|
|
87
|
-
}),
|
|
84
|
+
i.onload = () => n({
|
|
85
|
+
status: i.status,
|
|
86
|
+
text: i.responseText,
|
|
87
|
+
header: (e) => i.getResponseHeader(e)
|
|
88
|
+
}), i.onerror = () => r(new e({
|
|
88
89
|
status: 0,
|
|
89
90
|
detail: "Falha de rede no upload resumível."
|
|
90
|
-
})),
|
|
91
|
+
})), i.onabort = () => r(new DOMException("Aborted", "AbortError")), t.register(i), i.send(t.body);
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function S(e) {
|
|
94
95
|
let t = e.header("Upload-Offset");
|
|
95
96
|
if (t === null) return null;
|
|
96
97
|
let n = Number(t);
|
|
97
98
|
return Number.isFinite(n) && n >= 0 ? n : null;
|
|
98
99
|
}
|
|
99
|
-
function
|
|
100
|
+
function C(e) {
|
|
100
101
|
if (!e) return null;
|
|
101
102
|
try {
|
|
102
103
|
return JSON.parse(e);
|
|
@@ -104,162 +105,167 @@ function S(e) {
|
|
|
104
105
|
return e;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
var
|
|
108
|
-
function
|
|
109
|
-
return !
|
|
108
|
+
var w = /* @__PURE__ */ new Set([409, 412]);
|
|
109
|
+
function ne(e) {
|
|
110
|
+
return !n(e) || w.has(e.status) ? !0 : r(e.status);
|
|
110
111
|
}
|
|
111
|
-
function T(
|
|
112
|
-
let
|
|
113
|
-
return new
|
|
114
|
-
...
|
|
115
|
-
detail: o ?
|
|
112
|
+
function T(n, r) {
|
|
113
|
+
let i = C(n.text), a = t(n.status, i, { get: n.header }), o = typeof i == "object" && !!i && ("detail" in i || "message" in i);
|
|
114
|
+
return new e({
|
|
115
|
+
...a,
|
|
116
|
+
detail: o ? a.detail : r
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
-
let t = typeof window > "u" ? void 0 : window.location.href;
|
|
119
|
+
function re(e, t) {
|
|
120
120
|
try {
|
|
121
|
-
return new URL(e, t).href;
|
|
121
|
+
return new URL(e, s(t) ?? void 0).href;
|
|
122
122
|
} catch {
|
|
123
123
|
return e;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
let { endpoint:
|
|
126
|
+
function E(t) {
|
|
127
|
+
let { endpoint: n, file: r, chunkSize: i = p, metadata: s, headers: h = {}, getToken: _, getPrincipal: v, trustedOrigins: C, withCredentials: w = !1, csrf: E, key: D = y(n, r), storage: O = b(), retry: k, onProgress: A, onStateChange: j } = t, M = v ?? u(_)?.current, N = "idle", P = 0, F = null, I = null, L, R = !1, z = O ? g.get(O) : void 0, B = z?.() ?? 0;
|
|
128
|
+
function V() {
|
|
129
|
+
if (M) return d("p", M());
|
|
130
|
+
if (_) return d("t", _());
|
|
131
|
+
}
|
|
128
132
|
function H() {
|
|
129
|
-
if (
|
|
130
|
-
if (
|
|
133
|
+
if (M && d("p", M()) !== L) throw new m("principal");
|
|
134
|
+
if (z && z() !== B) throw new m("cleared");
|
|
131
135
|
}
|
|
132
136
|
let U = null, W = null, G = 0;
|
|
133
137
|
function K(e) {
|
|
134
|
-
|
|
138
|
+
N !== e && (N = e, j?.(e));
|
|
135
139
|
}
|
|
136
140
|
function q(e) {
|
|
137
|
-
|
|
141
|
+
A?.({
|
|
138
142
|
loaded: e,
|
|
139
|
-
total:
|
|
140
|
-
fraction:
|
|
143
|
+
total: r.size,
|
|
144
|
+
fraction: r.size === 0 ? 1 : e / r.size,
|
|
141
145
|
resumedFrom: G
|
|
142
146
|
});
|
|
143
147
|
}
|
|
144
|
-
function J(e,
|
|
145
|
-
let
|
|
146
|
-
...h,
|
|
147
|
-
"Tus-Resumable":
|
|
148
|
-
}, s =
|
|
149
|
-
return s && !("Authorization" in
|
|
150
|
-
method:
|
|
148
|
+
function J(e, t) {
|
|
149
|
+
let r = a(e, n, C), i = {
|
|
150
|
+
...r ? h : {},
|
|
151
|
+
"Tus-Resumable": f
|
|
152
|
+
}, s = _?.();
|
|
153
|
+
return s && !("Authorization" in h) && (r ? i.Authorization = `Bearer ${s}` : o(e, n)), Object.assign(i, c({
|
|
154
|
+
method: t,
|
|
151
155
|
url: e,
|
|
152
|
-
reference:
|
|
153
|
-
csrf:
|
|
156
|
+
reference: n,
|
|
157
|
+
csrf: E,
|
|
154
158
|
trustedOrigins: C,
|
|
155
159
|
headers: h
|
|
156
|
-
})),
|
|
160
|
+
})), i;
|
|
157
161
|
}
|
|
158
162
|
function Y(e) {
|
|
159
163
|
W = e;
|
|
160
164
|
}
|
|
161
165
|
async function X() {
|
|
162
|
-
|
|
163
|
-
url:
|
|
164
|
-
offset:
|
|
165
|
-
size:
|
|
166
|
-
idempotencyKey:
|
|
166
|
+
O && F && I && (H(), L = V(), await O.set(D, {
|
|
167
|
+
url: F,
|
|
168
|
+
offset: P,
|
|
169
|
+
size: r.size,
|
|
170
|
+
idempotencyKey: I,
|
|
167
171
|
updatedAt: Date.now(),
|
|
168
|
-
...
|
|
172
|
+
...L === void 0 ? {} : { owner: L }
|
|
169
173
|
}));
|
|
170
174
|
}
|
|
171
|
-
async function Z(
|
|
172
|
-
let
|
|
175
|
+
async function Z(t) {
|
|
176
|
+
let n = await x({
|
|
173
177
|
method: "HEAD",
|
|
174
|
-
url:
|
|
175
|
-
headers: J(
|
|
176
|
-
withCredentials:
|
|
178
|
+
url: t,
|
|
179
|
+
headers: J(t, "HEAD"),
|
|
180
|
+
withCredentials: w,
|
|
177
181
|
register: Y
|
|
178
182
|
});
|
|
179
|
-
if (
|
|
180
|
-
status:
|
|
183
|
+
if (n.status === 404 || n.status === 410) throw new e({
|
|
184
|
+
status: n.status,
|
|
181
185
|
detail: "O upload expirou no servidor. Comece de novo."
|
|
182
186
|
});
|
|
183
|
-
let
|
|
184
|
-
if (
|
|
185
|
-
return
|
|
187
|
+
let r = S(n);
|
|
188
|
+
if (r === null) throw T(n, "HEAD sem Upload-Offset.");
|
|
189
|
+
return r;
|
|
186
190
|
}
|
|
187
|
-
async function
|
|
188
|
-
let e =
|
|
189
|
-
|
|
190
|
-
let t =
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
async function ie() {
|
|
192
|
+
let e = V();
|
|
193
|
+
R && M && e !== L && (I = null);
|
|
194
|
+
let t = R && !M ? F : null;
|
|
195
|
+
L = e, R = !0, B = z?.() ?? 0;
|
|
196
|
+
let i = O ? await O.get(D) : null, a = i !== null && t !== null && i.url === t;
|
|
197
|
+
if (i && L !== void 0 && i.owner !== L && !a && (await O?.delete(D), i = null), i && i.size === r.size && (I = i.idempotencyKey, i.url)) try {
|
|
198
|
+
return P = await Z(i.url), F = i.url, i.url;
|
|
193
199
|
} catch {
|
|
194
|
-
|
|
200
|
+
P = 0;
|
|
195
201
|
}
|
|
196
|
-
K("creating"),
|
|
202
|
+
K("creating"), I ??= ee(), F = null, P = 0, O && await O.set(D, {
|
|
197
203
|
url: "",
|
|
198
204
|
offset: 0,
|
|
199
|
-
size:
|
|
200
|
-
idempotencyKey:
|
|
205
|
+
size: r.size,
|
|
206
|
+
idempotencyKey: I,
|
|
201
207
|
updatedAt: Date.now(),
|
|
202
|
-
...
|
|
208
|
+
...L === void 0 ? {} : { owner: L }
|
|
203
209
|
});
|
|
204
|
-
let
|
|
205
|
-
...J(
|
|
206
|
-
"Upload-Length": String(
|
|
207
|
-
"Idempotency-Key":
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
let
|
|
210
|
+
let o = {
|
|
211
|
+
...J(n, "POST"),
|
|
212
|
+
"Upload-Length": String(r.size),
|
|
213
|
+
"Idempotency-Key": I
|
|
214
|
+
}, c = te(s);
|
|
215
|
+
c && (o["Upload-Metadata"] = c);
|
|
216
|
+
let l = await x({
|
|
211
217
|
method: "POST",
|
|
212
|
-
url:
|
|
213
|
-
headers:
|
|
214
|
-
withCredentials:
|
|
218
|
+
url: n,
|
|
219
|
+
headers: o,
|
|
220
|
+
withCredentials: w,
|
|
215
221
|
register: Y
|
|
216
222
|
});
|
|
217
|
-
if (
|
|
218
|
-
let
|
|
219
|
-
if (!
|
|
220
|
-
return
|
|
223
|
+
if (l.status !== 201) throw T(l, "Criação do upload recusada.");
|
|
224
|
+
let u = l.header("Location");
|
|
225
|
+
if (!u) throw T(l, "Criação do upload sem cabeçalho Location.");
|
|
226
|
+
return F = re(u, n), await X(), F;
|
|
221
227
|
}
|
|
222
|
-
async function
|
|
223
|
-
if (H(), t.needed && (
|
|
224
|
-
let n = Math.min(
|
|
228
|
+
async function ae(e, t) {
|
|
229
|
+
if (H(), t.needed && (P = await Z(e), t.needed = !1, q(P), await X(), P >= r.size)) return;
|
|
230
|
+
let n = Math.min(P + i, r.size), a = P, o = await x({
|
|
225
231
|
method: "PATCH",
|
|
226
232
|
url: e,
|
|
227
233
|
headers: {
|
|
228
234
|
...J(e, "PATCH"),
|
|
229
235
|
"Content-Type": "application/offset+octet-stream",
|
|
230
|
-
"Upload-Offset": String(
|
|
236
|
+
"Upload-Offset": String(a)
|
|
231
237
|
},
|
|
232
|
-
body:
|
|
233
|
-
withCredentials:
|
|
234
|
-
onProgress: (e) => q(Math.min(
|
|
238
|
+
body: r.slice(a, n),
|
|
239
|
+
withCredentials: w,
|
|
240
|
+
onProgress: (e) => q(Math.min(a + e, r.size)),
|
|
235
241
|
register: Y
|
|
236
242
|
});
|
|
237
|
-
if (
|
|
238
|
-
if (
|
|
239
|
-
|
|
243
|
+
if (o.status === 409 || o.status === 412) throw t.needed = !0, T(o, "Offset divergente — o servidor já tinha esses bytes.");
|
|
244
|
+
if (o.status !== 204 && o.status !== 200) throw T(o, "Chunk recusado pelo servidor.");
|
|
245
|
+
P = S(o) ?? n, q(P), await X();
|
|
240
246
|
}
|
|
241
|
-
async function
|
|
247
|
+
async function oe() {
|
|
242
248
|
U = null;
|
|
243
|
-
let e = await
|
|
244
|
-
G =
|
|
249
|
+
let e = await ie();
|
|
250
|
+
G = P, K("uploading"), q(P);
|
|
245
251
|
let t = { needed: !1 };
|
|
246
|
-
for (;
|
|
252
|
+
for (; P < r.size && !U;) await l(() => ae(e, t), {
|
|
247
253
|
retries: 5,
|
|
248
|
-
...
|
|
254
|
+
...k,
|
|
249
255
|
shouldRetry: (e, n) => {
|
|
250
|
-
if (U || e instanceof
|
|
251
|
-
let r =
|
|
256
|
+
if (U || e instanceof m || e instanceof DOMException && e.name === "AbortError") return !1;
|
|
257
|
+
let r = k?.shouldRetry?.(e, n) ?? ne(e);
|
|
252
258
|
return r && (t.needed = !0), r;
|
|
253
259
|
}
|
|
254
260
|
});
|
|
255
|
-
return U === "pause" ? (K("paused"), null) : U === "abort" ? (K("aborted"), null) : (K("done"),
|
|
261
|
+
return U === "pause" ? (K("paused"), null) : U === "abort" ? (K("aborted"), null) : (K("done"), O && await O.delete(D), {
|
|
256
262
|
url: e,
|
|
257
|
-
size:
|
|
263
|
+
size: r.size
|
|
258
264
|
});
|
|
259
265
|
}
|
|
260
266
|
async function Q() {
|
|
261
267
|
try {
|
|
262
|
-
return await
|
|
268
|
+
return await oe();
|
|
263
269
|
} catch (e) {
|
|
264
270
|
if (U !== null || e instanceof DOMException && e.name === "AbortError") return K(U === "abort" ? "aborted" : "paused"), null;
|
|
265
271
|
throw K("error"), e;
|
|
@@ -275,27 +281,27 @@ function D(e) {
|
|
|
275
281
|
resume: Q,
|
|
276
282
|
pause: () => $("pause"),
|
|
277
283
|
abort: async ({ discard: e = !1 } = {}) => {
|
|
278
|
-
$("abort"), K("aborted"), e && (
|
|
284
|
+
$("abort"), K("aborted"), e && (F && await x({
|
|
279
285
|
method: "DELETE",
|
|
280
|
-
url:
|
|
281
|
-
headers: J(
|
|
282
|
-
withCredentials:
|
|
286
|
+
url: F,
|
|
287
|
+
headers: J(F, "DELETE"),
|
|
288
|
+
withCredentials: w,
|
|
283
289
|
register: () => void 0
|
|
284
|
-
}).catch(() => void 0),
|
|
290
|
+
}).catch(() => void 0), O && await O.delete(D));
|
|
285
291
|
},
|
|
286
292
|
get state() {
|
|
287
|
-
return
|
|
293
|
+
return N;
|
|
288
294
|
},
|
|
289
295
|
get offset() {
|
|
290
|
-
return
|
|
296
|
+
return P;
|
|
291
297
|
},
|
|
292
298
|
get url() {
|
|
293
|
-
return
|
|
299
|
+
return F;
|
|
294
300
|
},
|
|
295
|
-
key:
|
|
301
|
+
key: D
|
|
296
302
|
};
|
|
297
303
|
}
|
|
298
304
|
//#endregion
|
|
299
|
-
export {
|
|
305
|
+
export { p as DEFAULT_CHUNK_SIZE, m as ResumableUploadSupersededError, f as TUS_VERSION, b as createLocalUploadStorage, E as createResumableUpload, y as uploadFingerprint };
|
|
300
306
|
|
|
301
307
|
//# sourceMappingURL=resumable-upload.js.map
|