useblocks 1.1.62 → 1.1.64
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/iframe/js/amp.BP7EklKo.js +1 -1
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.js +1 -1
- package/iframe/js/rules.4N5s3OV-.js +1 -1
- package/npm-publish.manifest.json +7 -7
- package/package.json +1 -1
- package/singlepage_headless_plugin.html +1 -1
- package/static/core/{907e6f1b.js → 261ad211.js} +3 -3
- package/static/core/{40952073.js → 40f1c391.js} +6 -6
- package/static/core/{8d78b13f.js → 411c06d9.js} +3 -3
- package/static/core/{bd26a4bd.js → 47513981.js} +7 -7
- package/static/core/{585cff60.js → 6c0b4555.js} +3 -3
- package/static/core/{d2fd1146.js → 7735c90f.js} +194 -171
- package/static/core/{da50e420.js → 7dd91b5f.js} +4036 -4043
- package/static/core/{fe238779.js → 90f16a4b.js} +7 -7
- package/static/core/{7a98c428.js → 9e889fa1.js} +4 -4
- package/static/core/{af4d7f64.js → a44b0f6c.js} +5 -5
- package/static/core/{c555dd21.js → b0712bbb.js} +5 -5
- package/static/core/{3500cc9c.js → bcee99d6.js} +30 -2
- package/static/core/{e5b1c38d.js → e96aadfa.js} +7 -7
- package/two_step_headless_plugin.html +1 -1
- package/{useblocks-core.194e3b23.js → useblocks-core.d874510b.js} +6 -6
- package/useblocks-esm.js +3 -3
- package/useblocks.js +3 -3
- /package/iframe/{iframe-eblock.194e3b23.html → iframe-eblock.d874510b.html} +0 -0
- /package/iframe/{iframe.194e3b23.html → iframe.d874510b.html} +0 -0
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
__useblocks__.define("static/core/
|
|
1
|
+
__useblocks__.define("static/core/7735c90f.js", [
|
|
2
2
|
"require",
|
|
3
3
|
"exports",
|
|
4
4
|
"module",
|
|
5
|
-
"static/core/
|
|
6
|
-
"static/core/
|
|
7
|
-
"static/core/
|
|
8
|
-
"static/core/
|
|
9
|
-
], function(
|
|
10
|
-
const h =
|
|
11
|
-
var
|
|
12
|
-
(function(
|
|
13
|
-
function e(
|
|
14
|
-
if (
|
|
15
|
-
if (
|
|
16
|
-
for (let
|
|
5
|
+
"static/core/bcee99d6.js",
|
|
6
|
+
"static/core/6c0b4555.js",
|
|
7
|
+
"static/core/411c06d9.js",
|
|
8
|
+
"static/core/40f1c391.js"
|
|
9
|
+
], function(_, I, z) {
|
|
10
|
+
const h = _("./bcee99d6.js"), P = _("./6c0b4555.js"), S = _("./411c06d9.js"), f = _("./40f1c391.js");
|
|
11
|
+
var F;
|
|
12
|
+
(function(d) {
|
|
13
|
+
function e(a, i, n = (s, o) => s === o) {
|
|
14
|
+
if (a === i) return !0;
|
|
15
|
+
if (a.length !== i.length) return !1;
|
|
16
|
+
for (let s = 0; s < a.length; s++) if (!n(a[s], i[s])) return !1;
|
|
17
17
|
return !0;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
function t(
|
|
19
|
+
d.isEqual = e;
|
|
20
|
+
function t(a, i = (n) => n) {
|
|
21
21
|
const n = new Set();
|
|
22
|
-
return
|
|
23
|
-
const o = i(
|
|
22
|
+
return a.filter((s) => {
|
|
23
|
+
const o = i(s);
|
|
24
24
|
return n.has(o) ? !1 : (n.add(o), !0);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
function r(
|
|
29
|
-
const
|
|
30
|
-
for (const
|
|
31
|
-
const u = i.find((g) => n(
|
|
27
|
+
d.unique = t;
|
|
28
|
+
function r(a = [], i = [], n = (s, o) => s === o) {
|
|
29
|
+
const s = [], o = [], p = [];
|
|
30
|
+
for (const l of a) {
|
|
31
|
+
const u = i.find((g) => n(l, g));
|
|
32
32
|
u ? p.push({
|
|
33
|
-
prev:
|
|
33
|
+
prev: l,
|
|
34
34
|
next: u
|
|
35
|
-
}) : o.push(
|
|
35
|
+
}) : o.push(l);
|
|
36
36
|
}
|
|
37
|
-
for (const
|
|
37
|
+
for (const l of i) a.find((u) => n(l, u)) || s.push(l);
|
|
38
38
|
return {
|
|
39
|
-
added:
|
|
39
|
+
added: s,
|
|
40
40
|
removed: o,
|
|
41
41
|
exists: p
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
})(
|
|
44
|
+
d.diff = r;
|
|
45
|
+
})(F || (F = {}));
|
|
46
46
|
var c = class E extends Error {
|
|
47
47
|
code;
|
|
48
48
|
status;
|
|
@@ -50,53 +50,66 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
50
50
|
get httpStatus() {
|
|
51
51
|
return this.status;
|
|
52
52
|
}
|
|
53
|
-
constructor(e, t, r,
|
|
54
|
-
super(e), this.name = "FileManagerApiError", this.code = t, this.status = r, this.details =
|
|
53
|
+
constructor(e, t, r, a) {
|
|
54
|
+
super(e), this.name = "FileManagerApiError", this.code = t, this.status = r, this.details = a, Error.captureStackTrace && Error.captureStackTrace(this, E);
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
function y(
|
|
58
|
-
return
|
|
57
|
+
function y(d) {
|
|
58
|
+
return d.replace(/\/+$/, "");
|
|
59
59
|
}
|
|
60
|
-
function C(
|
|
61
|
-
const t = y(h.buildCdnFileUrl(e ?? {}, [])), r = y(
|
|
60
|
+
function C(d, e) {
|
|
61
|
+
const t = y(h.buildCdnFileUrl(e ?? {}, [])), r = y(d);
|
|
62
62
|
if (!(!t || !r.startsWith(`${t}/`))) return r.slice(t.length + 1).split("/").filter(Boolean)[0];
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function U(d, e = {}) {
|
|
65
65
|
const t = e.projectId?.trim();
|
|
66
66
|
if (!t) return !1;
|
|
67
|
-
const r = h.unwrapResourceProxyUrl(
|
|
67
|
+
const r = h.unwrapResourceProxyUrl(d, e.appConfig, e.isStandalone);
|
|
68
68
|
return h.isCdnUrl(r, e.appConfig) ? C(r, e.appConfig) === t : !1;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return h.unwrapResourceProxyUrl(
|
|
70
|
+
function k(d, e = {}) {
|
|
71
|
+
return h.unwrapResourceProxyUrl(d, e.appConfig, e.isStandalone);
|
|
72
72
|
}
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
73
|
+
var b = {
|
|
74
|
+
"platform.validation": "ValidationError",
|
|
75
|
+
"platform.malformed_body": "ValidationError",
|
|
76
|
+
"platform.invalid_uuid": "ValidationError",
|
|
77
|
+
"platform.invalid_field_value": "ValidationError",
|
|
78
|
+
"platform.unauthorized": "AuthenticationFailed",
|
|
79
|
+
"platform.forbidden": "AuthorizationFailed",
|
|
80
|
+
"platform.not_found": "FileNotFound",
|
|
81
|
+
"platform.conflict": "FolderAlreadyExists",
|
|
82
|
+
"platform.payload_too_large": "PayloadTooLarge",
|
|
83
|
+
"platform.unsupported_media_type": "FileTypeNotAllowed",
|
|
84
|
+
"platform.too_many_requests": "RateLimitExceeded",
|
|
85
|
+
"platform.unavailable": "ServiceUnavailable",
|
|
86
|
+
"platform.internal": "BackendError",
|
|
87
|
+
"filemanager.file_not_found": "FileNotFound",
|
|
88
|
+
"filemanager.folder_not_found": "FolderNotFound",
|
|
89
|
+
"filemanager.file_exists": "FileAlreadyExists",
|
|
90
|
+
"filemanager.folder_exists": "FolderAlreadyExists",
|
|
91
|
+
"filemanager.invalid_file_name": "FileInvalidName",
|
|
92
|
+
"filemanager.invalid_folder_name": "FolderInvalidName",
|
|
93
|
+
"filemanager.item_not_found": "FileNotFound",
|
|
94
|
+
"filemanager.no_project_access": "AuthorizationFailed",
|
|
95
|
+
"filemanager.project_required": "ValidationError",
|
|
96
|
+
"filemanager.invalid_project_id": "ValidationError",
|
|
97
|
+
"filemanager.file_too_large": "FileTooLarge",
|
|
98
|
+
"filemanager.upload_too_large": "PayloadTooLarge",
|
|
99
|
+
"filemanager.no_files": "ValidationError",
|
|
100
|
+
"filemanager.batch_limit_exceeded": "BatchItemLimitExceeded",
|
|
101
|
+
"filemanager.too_many_items": "BatchItemLimitExceeded",
|
|
102
|
+
"filemanager.items_required": "ValidationError",
|
|
103
|
+
"filemanager.unsupported_file_type": "FileTypeNotAllowed",
|
|
104
|
+
"filemanager.upload_url_rejected": "UploadUrlInvalid",
|
|
105
|
+
"filemanager.transfer_into_descendant": "MoveIntoDescendant",
|
|
106
|
+
"filemanager.legacy_file_unsupported": "UnsupportedOperation",
|
|
107
|
+
"filemanager.backfill_unsupported": "UnsupportedOperation",
|
|
108
|
+
"filemanager.backfill_already_done": "UnsupportedOperation",
|
|
109
|
+
"filemanager.storage_unavailable": "ServiceUnavailable"
|
|
97
110
|
};
|
|
98
|
-
function
|
|
99
|
-
switch (
|
|
111
|
+
function w(d) {
|
|
112
|
+
switch (d) {
|
|
100
113
|
case 400: return "ValidationError";
|
|
101
114
|
case 401: return "AuthenticationFailed";
|
|
102
115
|
case 403: return "AuthorizationFailed";
|
|
@@ -110,7 +123,17 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
110
123
|
default: return "BackendError";
|
|
111
124
|
}
|
|
112
125
|
}
|
|
113
|
-
|
|
126
|
+
function x(d, e) {
|
|
127
|
+
return (d ? b[d] : void 0) ?? w(e);
|
|
128
|
+
}
|
|
129
|
+
function A(d) {
|
|
130
|
+
return (d ? b[d] : void 0) ?? "FileWriteError";
|
|
131
|
+
}
|
|
132
|
+
var v = 2e3, j = 30, M = v * j;
|
|
133
|
+
function O(d) {
|
|
134
|
+
return typeof d?.watchThumbnail == "function";
|
|
135
|
+
}
|
|
136
|
+
var T = 200, N = class m {
|
|
114
137
|
pathMode = !1;
|
|
115
138
|
rootId = "";
|
|
116
139
|
trashPath = f.Xi;
|
|
@@ -133,46 +156,46 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
133
156
|
async getItems(e) {
|
|
134
157
|
const t = e.folderId === f.Xi;
|
|
135
158
|
if (e.itemType === "folder") return { items: await this.listFolders(e.folderId, t) };
|
|
136
|
-
const r = e.itemType === "all" && (e.page ?? 1) <= 1, [
|
|
159
|
+
const r = e.itemType === "all" && (e.page ?? 1) <= 1, [a, i] = await Promise.all([r ? this.listFolders(e.folderId, t, e.search) : [], this.listFiles(e, t)]);
|
|
137
160
|
return {
|
|
138
|
-
items: [...
|
|
161
|
+
items: [...a, ...i.items],
|
|
139
162
|
pagination: i.pagination
|
|
140
163
|
};
|
|
141
164
|
}
|
|
142
165
|
async listFolders(e, t, r) {
|
|
143
|
-
const
|
|
166
|
+
const a = await this.api.folders.foldersList({
|
|
144
167
|
project_id: this.projectId,
|
|
145
168
|
parent_id: t ? void 0 : this.normalizeFolderId(e),
|
|
146
169
|
trashed: t || void 0
|
|
147
170
|
});
|
|
148
171
|
try {
|
|
149
|
-
this.assertOk(
|
|
172
|
+
this.assertOk(a);
|
|
150
173
|
} catch (n) {
|
|
151
174
|
if (m.isNotFound(n)) return [];
|
|
152
175
|
throw n;
|
|
153
176
|
}
|
|
154
|
-
let i = (
|
|
177
|
+
let i = (a.data.items ?? []).map((n) => this.mapFolder(n, e));
|
|
155
178
|
if (r) {
|
|
156
179
|
const n = r.toLowerCase();
|
|
157
|
-
i = i.filter((
|
|
180
|
+
i = i.filter((s) => s.name.toLowerCase().includes(n));
|
|
158
181
|
}
|
|
159
182
|
return i;
|
|
160
183
|
}
|
|
161
184
|
async listFiles(e, t) {
|
|
162
|
-
const r = Math.min(e.limit ?? T, T),
|
|
185
|
+
const r = Math.min(e.limit ?? T, T), a = Math.max(e.page ?? 1, 1), i = await this.api.files.filesList({
|
|
163
186
|
project_id: this.projectId,
|
|
164
187
|
folder_id: t ? void 0 : this.normalizeFolderId(e.folderId),
|
|
165
188
|
search: e.search || void 0,
|
|
166
189
|
sort_by: e.sortBy,
|
|
167
190
|
sort_order: e.sortOrder,
|
|
168
191
|
limit: r,
|
|
169
|
-
offset: (
|
|
192
|
+
offset: (a - 1) * r,
|
|
170
193
|
trashed: t || void 0
|
|
171
194
|
});
|
|
172
195
|
try {
|
|
173
|
-
this.assertOk(i
|
|
174
|
-
} catch (
|
|
175
|
-
if (m.isNotFound(
|
|
196
|
+
this.assertOk(i);
|
|
197
|
+
} catch (s) {
|
|
198
|
+
if (m.isNotFound(s)) return {
|
|
176
199
|
items: [],
|
|
177
200
|
pagination: {
|
|
178
201
|
page: 1,
|
|
@@ -183,12 +206,12 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
183
206
|
hasPrev: !1
|
|
184
207
|
}
|
|
185
208
|
};
|
|
186
|
-
throw
|
|
209
|
+
throw s;
|
|
187
210
|
}
|
|
188
211
|
this.onIndexingStateChange?.(!!i.data.indexing);
|
|
189
212
|
const n = t ? f.Xi : this.normalizeFolderId(e.folderId) ?? this.rootId;
|
|
190
213
|
return {
|
|
191
|
-
items: (i.data.data ?? []).map((
|
|
214
|
+
items: (i.data.data ?? []).map((s) => this.mapFile(s, n)),
|
|
192
215
|
pagination: this.mapPagination(i.data.page, r)
|
|
193
216
|
};
|
|
194
217
|
}
|
|
@@ -215,53 +238,53 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
215
238
|
};
|
|
216
239
|
const t = new Map();
|
|
217
240
|
e.items.forEach((i, n) => {
|
|
218
|
-
const
|
|
241
|
+
const s = this.normalizeFolderId(i.folderId ?? e.folderId ?? void 0) ?? this.rootId, o = i.requestId ?? `item-${n}`, p = t.get(s) ?? [];
|
|
219
242
|
p.push({
|
|
220
243
|
item: i,
|
|
221
244
|
requestId: o
|
|
222
|
-
}), t.set(
|
|
245
|
+
}), t.set(s, p);
|
|
223
246
|
});
|
|
224
247
|
const r = [];
|
|
225
248
|
for (const [i, n] of t) {
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
for (const { item:
|
|
249
|
+
const s = new FormData();
|
|
250
|
+
s.append("project_id", this.projectId), i !== this.rootId && s.append("folder_id", i);
|
|
251
|
+
for (const { item: l, requestId: u } of n) s.append("request_id", u), s.append("file", l.data, l.name);
|
|
229
252
|
let o;
|
|
230
253
|
try {
|
|
231
254
|
o = await this.api.request({
|
|
232
255
|
path: "/files",
|
|
233
256
|
method: "POST",
|
|
234
|
-
body:
|
|
257
|
+
body: s,
|
|
235
258
|
type: h.ContentType.FormData,
|
|
236
259
|
format: "json",
|
|
237
260
|
secure: !0
|
|
238
|
-
}), this.assertOk(o
|
|
239
|
-
} catch (
|
|
261
|
+
}), this.assertOk(o);
|
|
262
|
+
} catch (l) {
|
|
240
263
|
for (const { requestId: u } of n) r.push({
|
|
241
264
|
requestId: u,
|
|
242
265
|
success: !1,
|
|
243
|
-
error: m.toErrorInfo(
|
|
266
|
+
error: m.toErrorInfo(l)
|
|
244
267
|
});
|
|
245
268
|
continue;
|
|
246
269
|
}
|
|
247
|
-
const p = new Map((o.data.items ?? []).map((
|
|
248
|
-
n.forEach(({ requestId:
|
|
249
|
-
const g = p.get(
|
|
270
|
+
const p = new Map((o.data.items ?? []).map((l) => [l.request_id, l]));
|
|
271
|
+
n.forEach(({ requestId: l }, u) => {
|
|
272
|
+
const g = p.get(l) ?? o.data.items?.[u];
|
|
250
273
|
g?.file ? r.push({
|
|
251
|
-
requestId:
|
|
274
|
+
requestId: l,
|
|
252
275
|
success: !0,
|
|
253
276
|
data: this.mapFile(g.file, i)
|
|
254
277
|
}) : r.push({
|
|
255
|
-
requestId:
|
|
278
|
+
requestId: l,
|
|
256
279
|
success: !1,
|
|
257
280
|
error: this.mapItemFail(g?.error)
|
|
258
281
|
});
|
|
259
282
|
});
|
|
260
283
|
}
|
|
261
|
-
const
|
|
284
|
+
const a = r.filter((i) => !i.success);
|
|
262
285
|
return {
|
|
263
|
-
success:
|
|
264
|
-
error:
|
|
286
|
+
success: a.length === 0,
|
|
287
|
+
error: a[0]?.error,
|
|
265
288
|
detailed: r
|
|
266
289
|
};
|
|
267
290
|
}
|
|
@@ -282,8 +305,8 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
282
305
|
async updateFile(e, t) {
|
|
283
306
|
let r = { id: e.id };
|
|
284
307
|
if (t.data !== void 0) {
|
|
285
|
-
const
|
|
286
|
-
i.append("project_id", this.projectId), i.append("file",
|
|
308
|
+
const a = typeof t.data == "string" ? m.base64ToBlob(t.data, e.type) : t.data, i = new FormData();
|
|
309
|
+
i.append("project_id", this.projectId), i.append("file", a, e.name);
|
|
287
310
|
const n = await this.api.request({
|
|
288
311
|
path: `/files/${e.id}/content`,
|
|
289
312
|
method: "PUT",
|
|
@@ -292,23 +315,23 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
292
315
|
format: "json",
|
|
293
316
|
secure: !0
|
|
294
317
|
});
|
|
295
|
-
this.assertOk(n
|
|
296
|
-
const
|
|
318
|
+
this.assertOk(n);
|
|
319
|
+
const s = n.data.file ?? {};
|
|
297
320
|
r = {
|
|
298
321
|
...r,
|
|
299
|
-
size:
|
|
300
|
-
type:
|
|
301
|
-
url:
|
|
302
|
-
thumbnail:
|
|
303
|
-
thumbnailUrl:
|
|
304
|
-
lastEdited:
|
|
322
|
+
size: s.size,
|
|
323
|
+
type: s.mime,
|
|
324
|
+
url: s.url,
|
|
325
|
+
thumbnail: s.thumbnail_url,
|
|
326
|
+
thumbnailUrl: s.thumbnail_url,
|
|
327
|
+
lastEdited: s.updated_at
|
|
305
328
|
};
|
|
306
329
|
}
|
|
307
330
|
if (t.name && t.name !== e.name) {
|
|
308
|
-
const
|
|
331
|
+
const a = await this.renameItem(e, t.name);
|
|
309
332
|
r = {
|
|
310
333
|
...r,
|
|
311
|
-
...
|
|
334
|
+
...a
|
|
312
335
|
};
|
|
313
336
|
}
|
|
314
337
|
return r;
|
|
@@ -316,26 +339,26 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
316
339
|
getFileData = async (e, t) => {
|
|
317
340
|
const { __: r } = this.i18n;
|
|
318
341
|
if (!e.url) throw new c(r("Failed to get file: %s").replace("%s", e.name), "FileReadError");
|
|
319
|
-
const
|
|
342
|
+
const a = await h.fetchWithResourceProxy(e.url, {
|
|
320
343
|
config: this.appConfig,
|
|
321
344
|
standalone: this.isStandalone,
|
|
322
345
|
resourceType: h.isCdnUrl(e.url, this.appConfig) ? "cdn" : "generic",
|
|
323
346
|
intent: "downloadBlob",
|
|
324
347
|
init: t?.forceReload ? { cache: "no-store" } : void 0
|
|
325
348
|
});
|
|
326
|
-
if (
|
|
327
|
-
throw new c(await
|
|
349
|
+
if (a.ok) return a.blob();
|
|
350
|
+
throw new c(await a.text() || r("Failed to get file: %s").replace("%s", a.statusText), w(a.status), a.status);
|
|
328
351
|
};
|
|
329
352
|
static base64ToBlob(e, t) {
|
|
330
|
-
const r = e.includes(",") ? e.slice(e.indexOf(",") + 1) : e,
|
|
331
|
-
for (let n = 0; n <
|
|
353
|
+
const r = e.includes(",") ? e.slice(e.indexOf(",") + 1) : e, a = atob(r), i = new Uint8Array(a.length);
|
|
354
|
+
for (let n = 0; n < a.length; n += 1) i[n] = a.charCodeAt(n);
|
|
332
355
|
return new Blob([i], t ? { type: t } : void 0);
|
|
333
356
|
}
|
|
334
357
|
mapItemFail(e) {
|
|
335
358
|
const { __: t } = this.i18n;
|
|
336
359
|
return {
|
|
337
360
|
message: e?.message || t("Unknown error"),
|
|
338
|
-
code: (e?.code
|
|
361
|
+
code: A(e?.code)
|
|
339
362
|
};
|
|
340
363
|
}
|
|
341
364
|
async renameItem(e, t) {
|
|
@@ -344,7 +367,7 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
344
367
|
project_id: this.projectId,
|
|
345
368
|
name: t
|
|
346
369
|
});
|
|
347
|
-
this.assertOk(i
|
|
370
|
+
this.assertOk(i);
|
|
348
371
|
const n = i.data.folder ?? {};
|
|
349
372
|
return {
|
|
350
373
|
id: e.id,
|
|
@@ -359,19 +382,19 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
359
382
|
name: t,
|
|
360
383
|
mode: "replace"
|
|
361
384
|
});
|
|
362
|
-
this.assertOk(r
|
|
363
|
-
const
|
|
385
|
+
this.assertOk(r);
|
|
386
|
+
const a = r.data.file ?? {};
|
|
364
387
|
return {
|
|
365
388
|
id: e.id,
|
|
366
|
-
name:
|
|
367
|
-
folderId:
|
|
389
|
+
name: a.name ?? t,
|
|
390
|
+
folderId: a.folder_id ?? e.folderId,
|
|
368
391
|
isFolder: !1,
|
|
369
|
-
url:
|
|
370
|
-
thumbnail:
|
|
371
|
-
thumbnailUrl:
|
|
372
|
-
extension:
|
|
373
|
-
type:
|
|
374
|
-
lastEdited:
|
|
392
|
+
url: a.url,
|
|
393
|
+
thumbnail: a.thumbnail_url,
|
|
394
|
+
thumbnailUrl: a.thumbnail_url,
|
|
395
|
+
extension: a.ext,
|
|
396
|
+
type: a.mime,
|
|
397
|
+
lastEdited: a.updated_at
|
|
375
398
|
};
|
|
376
399
|
}
|
|
377
400
|
async deleteItem(e, t) {
|
|
@@ -382,14 +405,14 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
382
405
|
project_id: this.projectId,
|
|
383
406
|
permanent: t.permanent || void 0
|
|
384
407
|
});
|
|
385
|
-
this.assertOk(r
|
|
408
|
+
this.assertOk(r);
|
|
386
409
|
} else {
|
|
387
410
|
const r = await this.api.files.filesDelete({
|
|
388
411
|
id: e.id,
|
|
389
412
|
project_id: this.projectId,
|
|
390
413
|
permanent: t.permanent || void 0
|
|
391
414
|
});
|
|
392
|
-
this.assertOk(r
|
|
415
|
+
this.assertOk(r);
|
|
393
416
|
}
|
|
394
417
|
} catch (r) {
|
|
395
418
|
if (!m.isNotFound(r)) throw r;
|
|
@@ -397,29 +420,29 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
397
420
|
}
|
|
398
421
|
async deleteItems(e, t) {
|
|
399
422
|
if (e.length === 0) return { success: !0 };
|
|
400
|
-
const r = new Set(e.filter((
|
|
401
|
-
for (const
|
|
402
|
-
if (
|
|
423
|
+
const r = new Set(e.filter((s) => s.isFolder).map((s) => s.id)), a = new Set(e.filter((s) => r.has(s.folderId))), i = [];
|
|
424
|
+
for (const s of e) {
|
|
425
|
+
if (a.has(s)) {
|
|
403
426
|
i.push({
|
|
404
|
-
requestId:
|
|
427
|
+
requestId: s.id,
|
|
405
428
|
success: !0
|
|
406
429
|
});
|
|
407
430
|
continue;
|
|
408
431
|
}
|
|
409
432
|
try {
|
|
410
|
-
await this.deleteItem(
|
|
411
|
-
requestId:
|
|
433
|
+
await this.deleteItem(s, t), i.push({
|
|
434
|
+
requestId: s.id,
|
|
412
435
|
success: !0
|
|
413
436
|
});
|
|
414
437
|
} catch (o) {
|
|
415
438
|
i.push({
|
|
416
|
-
requestId:
|
|
439
|
+
requestId: s.id,
|
|
417
440
|
success: !1,
|
|
418
441
|
error: m.toErrorInfo(o)
|
|
419
442
|
});
|
|
420
443
|
}
|
|
421
444
|
}
|
|
422
|
-
const n = i.filter((
|
|
445
|
+
const n = i.filter((s) => !s.success);
|
|
423
446
|
return {
|
|
424
447
|
success: n.length === 0,
|
|
425
448
|
error: n[0]?.error,
|
|
@@ -431,25 +454,25 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
431
454
|
success: !0,
|
|
432
455
|
detailed: []
|
|
433
456
|
};
|
|
434
|
-
const r = e.filter((
|
|
457
|
+
const r = e.filter((s) => s.folderId === f.Xi), a = e.filter((s) => s.folderId !== f.Xi), i = [];
|
|
435
458
|
if (r.length > 0) {
|
|
436
|
-
const
|
|
459
|
+
const s = await this.api.trash.restoreCreate({
|
|
437
460
|
project_id: this.projectId,
|
|
438
461
|
ids: r.map((o) => o.id),
|
|
439
462
|
target_folder_id: this.normalizeFolderId(t),
|
|
440
463
|
on_conflict: "keep_both"
|
|
441
464
|
});
|
|
442
|
-
this.assertOk(
|
|
465
|
+
this.assertOk(s), i.push(...this.mapTransferResults(s.data.items, r));
|
|
443
466
|
}
|
|
444
|
-
if (
|
|
445
|
-
const
|
|
467
|
+
if (a.length > 0) {
|
|
468
|
+
const s = await this.api.items.moveCreate({
|
|
446
469
|
project_id: this.projectId,
|
|
447
|
-
ids:
|
|
470
|
+
ids: a.map((o) => o.id),
|
|
448
471
|
target_folder_id: this.normalizeFolderId(t)
|
|
449
472
|
});
|
|
450
|
-
this.assertOk(
|
|
473
|
+
this.assertOk(s), i.push(...this.mapTransferResults(s.data.items, a));
|
|
451
474
|
}
|
|
452
|
-
const n = i.filter((
|
|
475
|
+
const n = i.filter((s) => !s.success);
|
|
453
476
|
return {
|
|
454
477
|
success: n.length === 0,
|
|
455
478
|
error: n[0]?.error,
|
|
@@ -470,11 +493,11 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
470
493
|
target_folder_id: this.normalizeFolderId(t)
|
|
471
494
|
});
|
|
472
495
|
this.assertOk(r);
|
|
473
|
-
const
|
|
496
|
+
const a = this.mapTransferResults(r.data.items, e), i = a.filter((n) => !n.success);
|
|
474
497
|
return {
|
|
475
498
|
success: i.length === 0,
|
|
476
499
|
error: i[0]?.error,
|
|
477
|
-
detailed:
|
|
500
|
+
detailed: a
|
|
478
501
|
};
|
|
479
502
|
}
|
|
480
503
|
async copyItem(e, t) {
|
|
@@ -497,35 +520,35 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
497
520
|
isStandalone: this.isStandalone,
|
|
498
521
|
projectId: this.projectId
|
|
499
522
|
};
|
|
500
|
-
if (!
|
|
501
|
-
const
|
|
523
|
+
if (!U(e, r)) return;
|
|
524
|
+
const a = k(e, r), i = P.decodeFileNameFromUrl(a);
|
|
502
525
|
if (!i) return;
|
|
503
526
|
const { items: n } = await this.listFiles({
|
|
504
527
|
folderId: t,
|
|
505
528
|
search: i
|
|
506
529
|
}, !1);
|
|
507
|
-
return n.find((
|
|
530
|
+
return n.find((s) => s.url === e || s.url === a);
|
|
508
531
|
}
|
|
509
532
|
mapTransferResults(e, t) {
|
|
510
|
-
const r = new Map(t.map((
|
|
511
|
-
return (e ?? []).map((
|
|
512
|
-
const n =
|
|
513
|
-
return
|
|
533
|
+
const r = new Map(t.map((a) => [a.id, a]));
|
|
534
|
+
return (e ?? []).map((a, i) => {
|
|
535
|
+
const n = a.id ?? t[i]?.id, s = n ? r.get(n) : t[i];
|
|
536
|
+
return a.error ? {
|
|
514
537
|
requestId: n,
|
|
515
538
|
success: !1,
|
|
516
|
-
error: this.mapItemFail(
|
|
539
|
+
error: this.mapItemFail(a.error)
|
|
517
540
|
} : {
|
|
518
541
|
requestId: n,
|
|
519
542
|
success: !0,
|
|
520
|
-
data:
|
|
543
|
+
data: a.file ? this.mapFile(a.file, a.file.folder_id ?? this.rootId) : a.folder ? this.mapFolder(a.folder) : s ? { id: s.id } : { id: n ?? "" }
|
|
521
544
|
};
|
|
522
545
|
});
|
|
523
546
|
}
|
|
524
547
|
unwrapSingleTransfer(e, t) {
|
|
525
548
|
const r = e.detailed?.[0];
|
|
526
549
|
if (!r?.success) {
|
|
527
|
-
const
|
|
528
|
-
throw
|
|
550
|
+
const a = r?.error ?? e.error;
|
|
551
|
+
throw a instanceof c ? a : new c(String(a?.message ?? this.i18n.__("Unknown error")), a?.code || "BackendError", typeof a?.status == "number" ? a.status : void 0);
|
|
529
552
|
}
|
|
530
553
|
return r.data ?? { id: t.id };
|
|
531
554
|
}
|
|
@@ -560,8 +583,8 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
560
583
|
watchThumbnail(e, t) {
|
|
561
584
|
const r = this.pendingThumbnails.get(e);
|
|
562
585
|
if (!r) return () => {};
|
|
563
|
-
const
|
|
564
|
-
if (
|
|
586
|
+
const a = this.thumbWatchers.get(r);
|
|
587
|
+
if (a) return a.listeners.add(t), () => a.listeners.delete(t);
|
|
565
588
|
const i = {
|
|
566
589
|
listeners: new Set([t]),
|
|
567
590
|
cancelled: !1
|
|
@@ -571,8 +594,8 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
571
594
|
};
|
|
572
595
|
}
|
|
573
596
|
async pollThumbnail(e, t, r) {
|
|
574
|
-
for (let
|
|
575
|
-
if (await new Promise((n) => setTimeout(n,
|
|
597
|
+
for (let a = 0; a < j; a += 1) {
|
|
598
|
+
if (await new Promise((n) => setTimeout(n, v)), r.cancelled) return;
|
|
576
599
|
let i;
|
|
577
600
|
try {
|
|
578
601
|
const n = await this.api.files.filesDetail({
|
|
@@ -601,23 +624,23 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
601
624
|
};
|
|
602
625
|
}
|
|
603
626
|
mapPagination(e, t) {
|
|
604
|
-
const r = e?.limit ?? t,
|
|
627
|
+
const r = e?.limit ?? t, a = e?.offset ?? 0, i = e?.total ?? 0, n = r > 0 ? Math.floor(a / r) + 1 : 1, s = r > 0 ? Math.ceil(i / r) : 0;
|
|
605
628
|
return {
|
|
606
629
|
page: n,
|
|
607
630
|
limit: r,
|
|
608
631
|
total: i,
|
|
609
|
-
totalPages:
|
|
610
|
-
hasNext: n <
|
|
632
|
+
totalPages: s,
|
|
633
|
+
hasNext: n < s,
|
|
611
634
|
hasPrev: n > 1
|
|
612
635
|
};
|
|
613
636
|
}
|
|
614
637
|
normalizeFolderId(e) {
|
|
615
638
|
if (!(!e || e === this.rootId)) return e;
|
|
616
639
|
}
|
|
617
|
-
assertOk(e
|
|
640
|
+
assertOk(e) {
|
|
618
641
|
if (e.ok && !e.error) return;
|
|
619
|
-
const { __:
|
|
620
|
-
throw new c(
|
|
642
|
+
const { __: t } = this.i18n, r = e.error?.error, a = x(r?.code, e.status);
|
|
643
|
+
throw new c(r?.message || t("Unknown error"), a, e.status);
|
|
621
644
|
}
|
|
622
645
|
static isNotFound(e) {
|
|
623
646
|
return e instanceof c && (e.code === "FileNotFound" || e.code === "FolderNotFound");
|
|
@@ -629,22 +652,22 @@ __useblocks__.define("static/core/d2fd1146.js", [
|
|
|
629
652
|
};
|
|
630
653
|
}
|
|
631
654
|
};
|
|
632
|
-
Object.defineProperty(
|
|
655
|
+
Object.defineProperty(I, "FileManagerApiError", {
|
|
633
656
|
enumerable: !0,
|
|
634
657
|
get: function() {
|
|
635
658
|
return c;
|
|
636
659
|
}
|
|
637
|
-
}), Object.defineProperty(
|
|
660
|
+
}), Object.defineProperty(I, "FileManagerRestApiProviderV2", {
|
|
638
661
|
enumerable: !0,
|
|
639
662
|
get: function() {
|
|
640
|
-
return
|
|
663
|
+
return N;
|
|
641
664
|
}
|
|
642
|
-
}), Object.defineProperty(
|
|
665
|
+
}), Object.defineProperty(I, "arrays", {
|
|
643
666
|
enumerable: !0,
|
|
644
667
|
get: function() {
|
|
645
|
-
return
|
|
668
|
+
return F;
|
|
646
669
|
}
|
|
647
|
-
}), Object.defineProperty(
|
|
670
|
+
}), Object.defineProperty(I, "hasThumbnailWatcher", {
|
|
648
671
|
enumerable: !0,
|
|
649
672
|
get: function() {
|
|
650
673
|
return O;
|