useblocks 1.1.49 → 1.1.53
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/runtime/THIRD_PARTY_LICENSES.txt +1 -1
- package/singlepage_headless_plugin.html +1 -1
- package/static/core/{8c81db36.js → 139e4380.js} +3 -3
- package/static/core/{1ca5f3772.js → 1995fb0a2.js} +10 -10
- package/static/core/{3b4845f7.js → 1f5e1fc9.js} +321 -321
- package/static/core/{59023866.js → 31e98e6e.js} +616 -611
- package/static/core/{13f581cc.js → 5318562c.js} +3 -3
- package/static/core/{386cf7b3.js → 75737a9d.js} +5156 -5116
- package/static/core/{11296a18.js → 9929a348.js} +107 -107
- package/static/core/{e7c24fe9.js → b408f33a.js} +179 -173
- package/static/core/{3dea3b87.js → bc7e3d2b.js} +7 -7
- package/static/core/{de79e0c5.js → c3058168.js} +524 -510
- package/static/core/ce0410b1.js +467 -0
- package/static/core/{339377b8.js → d1eb3c68.js} +13244 -13200
- package/static/core/{8e110c69.js → dc1f9e4f.js} +31 -31
- package/static/core/{7a229b90.js → e1d239ab.js} +41 -41
- package/static/core/{aacf134d.js → e5e07f1d.js} +514 -494
- package/static/core/{acb049cb.js → ebd852b6.js} +1267 -1265
- package/static/core/{c59f9731.js → ee0ddb51.js} +4036 -3900
- package/static/core/{13d197af.js → f3cff4c9.js} +169 -169
- package/two_step_headless_plugin.html +1 -1
- package/ui-kit/index.js +49 -47
- package/{useblocks-core.15a9129c.js → useblocks-core.2a5dade1.js} +6 -6
- package/useblocks-esm.js +3 -3
- package/useblocks.js +3 -3
- package/static/core/a11c28c2.js +0 -467
- /package/iframe/{iframe-eblock.15a9129c.html → iframe-eblock.2a5dade1.html} +0 -0
- /package/iframe/{iframe.15a9129c.html → iframe.2a5dade1.html} +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
__useblocks__.define("static/core/
|
|
1
|
+
__useblocks__.define("static/core/b408f33a.js", [
|
|
2
2
|
"require",
|
|
3
3
|
"exports",
|
|
4
4
|
"module",
|
|
5
|
-
"static/core/
|
|
6
|
-
"static/core/
|
|
7
|
-
"static/core/
|
|
8
|
-
"static/core/
|
|
9
|
-
"static/core/
|
|
10
|
-
], function(g, F,
|
|
11
|
-
const h = g("./
|
|
12
|
-
g("./
|
|
5
|
+
"static/core/ee0ddb51.js",
|
|
6
|
+
"static/core/5318562c.js",
|
|
7
|
+
"static/core/ebd852b6.js",
|
|
8
|
+
"static/core/75737a9d.js",
|
|
9
|
+
"static/core/1995fb0a2.js"
|
|
10
|
+
], function(g, F, B) {
|
|
11
|
+
const h = g("./ee0ddb51.js"), S = g("./5318562c.js"), P = g("./ebd852b6.js"), f = g("./75737a9d.js");
|
|
12
|
+
g("./1995fb0a2.js");
|
|
13
13
|
var _;
|
|
14
14
|
(function(l) {
|
|
15
15
|
function e(s, a, n = (i, o) => i === o) {
|
|
@@ -19,15 +19,15 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
19
19
|
return !0;
|
|
20
20
|
}
|
|
21
21
|
l.isEqual = e;
|
|
22
|
-
function
|
|
22
|
+
function t(s, a = (n) => n) {
|
|
23
23
|
const n = new Set();
|
|
24
24
|
return s.filter((i) => {
|
|
25
25
|
const o = a(i);
|
|
26
26
|
return n.has(o) ? !1 : (n.add(o), !0);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
l.unique =
|
|
30
|
-
function
|
|
29
|
+
l.unique = t;
|
|
30
|
+
function r(s = [], a = [], n = (i, o) => i === o) {
|
|
31
31
|
const i = [], o = [], p = [];
|
|
32
32
|
for (const d of s) {
|
|
33
33
|
const u = a.find((I) => n(d, I));
|
|
@@ -43,40 +43,40 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
43
43
|
exists: p
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
l.diff =
|
|
46
|
+
l.diff = r;
|
|
47
47
|
})(_ || (_ = {}));
|
|
48
|
-
var c = class
|
|
48
|
+
var c = class E extends Error {
|
|
49
49
|
code;
|
|
50
50
|
status;
|
|
51
51
|
details;
|
|
52
52
|
get httpStatus() {
|
|
53
53
|
return this.status;
|
|
54
54
|
}
|
|
55
|
-
constructor(e,
|
|
56
|
-
super(e), this.name = "FileManagerApiError", this.code =
|
|
55
|
+
constructor(e, t, r, s) {
|
|
56
|
+
super(e), this.name = "FileManagerApiError", this.code = t, this.status = r, this.details = s, Error.captureStackTrace && Error.captureStackTrace(this, E);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
function y(l) {
|
|
60
60
|
return l.replace(/\/+$/, "");
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
if (!(!
|
|
62
|
+
function C(l, e) {
|
|
63
|
+
const t = y(h.buildCdnFileUrl(e ?? {}, [])), r = y(l);
|
|
64
|
+
if (!(!t || !r.startsWith(`${t}/`))) return r.slice(t.length + 1).split("/").filter(Boolean)[0];
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
69
|
-
const
|
|
70
|
-
return h.isCdnUrl(
|
|
66
|
+
function U(l, e = {}) {
|
|
67
|
+
const t = e.projectId?.trim();
|
|
68
|
+
if (!t) return !1;
|
|
69
|
+
const r = h.unwrapResourceProxyUrl(l, e.appConfig, e.isStandalone);
|
|
70
|
+
return h.isCdnUrl(r, e.appConfig) ? C(r, e.appConfig) === t : !1;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function A(l, e = {}) {
|
|
73
73
|
return h.unwrapResourceProxyUrl(l, e.appConfig, e.isStandalone);
|
|
74
74
|
}
|
|
75
|
-
var
|
|
76
|
-
function
|
|
75
|
+
var w = 2e3, b = 30, k = w * b;
|
|
76
|
+
function M(l) {
|
|
77
77
|
return typeof l?.watchThumbnail == "function";
|
|
78
78
|
}
|
|
79
|
-
var
|
|
79
|
+
var j = 200, T = {
|
|
80
80
|
validation_error: "ValidationError",
|
|
81
81
|
unauthorized: "AuthenticationFailed",
|
|
82
82
|
forbidden: "AuthorizationFailed",
|
|
@@ -87,7 +87,7 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
87
87
|
too_many_requests: "RateLimitExceeded",
|
|
88
88
|
service_unavailable: "ServiceUnavailable",
|
|
89
89
|
internal_error: "BackendError"
|
|
90
|
-
},
|
|
90
|
+
}, O = {
|
|
91
91
|
file: {
|
|
92
92
|
not_found: "FileNotFound",
|
|
93
93
|
conflict: "FileAlreadyExists"
|
|
@@ -97,7 +97,7 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
97
97
|
conflict: "FolderAlreadyExists"
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
function
|
|
100
|
+
function v(l) {
|
|
101
101
|
switch (l) {
|
|
102
102
|
case 400: return "ValidationError";
|
|
103
103
|
case 401: return "AuthenticationFailed";
|
|
@@ -112,10 +112,10 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
112
112
|
default: return "BackendError";
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
var
|
|
115
|
+
var x = class m {
|
|
116
116
|
pathMode = !1;
|
|
117
117
|
rootId = "";
|
|
118
|
-
trashPath = f.
|
|
118
|
+
trashPath = f.Us;
|
|
119
119
|
useSoftDelete = !1;
|
|
120
120
|
api;
|
|
121
121
|
projectId;
|
|
@@ -127,25 +127,25 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
127
127
|
thumbWatchers = new Map();
|
|
128
128
|
resolveSystemFolderByPath;
|
|
129
129
|
constructor(e) {
|
|
130
|
-
this.api = e.restApi, this.projectId = e.projectId, this.i18n = e.i18n ??
|
|
131
|
-
id: f.
|
|
130
|
+
this.api = e.restApi, this.projectId = e.projectId, this.i18n = e.i18n ?? P.defaultI18nContext, this.appConfig = e.appConfig, this.isStandalone = e.isStandalone, this.onIndexingStateChange = e.onIndexingStateChange, this.resolveSystemFolderByPath = f.Bs({ Trash: {
|
|
131
|
+
id: f.Us,
|
|
132
132
|
folderId: this.rootId
|
|
133
133
|
} });
|
|
134
134
|
}
|
|
135
135
|
async getItems(e) {
|
|
136
|
-
const
|
|
137
|
-
if (e.itemType === "folder") return { items: await this.listFolders(e.folderId,
|
|
138
|
-
const
|
|
136
|
+
const t = e.folderId === f.Us;
|
|
137
|
+
if (e.itemType === "folder") return { items: await this.listFolders(e.folderId, t) };
|
|
138
|
+
const r = e.itemType === "all" && (e.page ?? 1) <= 1, [s, a] = await Promise.all([r ? this.listFolders(e.folderId, t, e.search) : [], this.listFiles(e, t)]);
|
|
139
139
|
return {
|
|
140
140
|
items: [...s, ...a.items],
|
|
141
141
|
pagination: a.pagination
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
async listFolders(e,
|
|
144
|
+
async listFolders(e, t, r) {
|
|
145
145
|
const s = await this.api.folders.foldersList({
|
|
146
146
|
project_id: this.projectId,
|
|
147
|
-
parent_id:
|
|
148
|
-
trashed:
|
|
147
|
+
parent_id: t ? void 0 : this.normalizeFolderId(e),
|
|
148
|
+
trashed: t || void 0
|
|
149
149
|
});
|
|
150
150
|
try {
|
|
151
151
|
this.assertOk(s, "folder");
|
|
@@ -154,22 +154,22 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
154
154
|
throw n;
|
|
155
155
|
}
|
|
156
156
|
let a = (s.data.items ?? []).map((n) => this.mapFolder(n, e));
|
|
157
|
-
if (
|
|
158
|
-
const n =
|
|
157
|
+
if (r) {
|
|
158
|
+
const n = r.toLowerCase();
|
|
159
159
|
a = a.filter((i) => i.name.toLowerCase().includes(n));
|
|
160
160
|
}
|
|
161
161
|
return a;
|
|
162
162
|
}
|
|
163
|
-
async listFiles(e,
|
|
164
|
-
const
|
|
163
|
+
async listFiles(e, t) {
|
|
164
|
+
const r = Math.min(e.limit ?? j, j), s = Math.max(e.page ?? 1, 1), a = await this.api.files.filesList({
|
|
165
165
|
project_id: this.projectId,
|
|
166
|
-
folder_id:
|
|
166
|
+
folder_id: t ? void 0 : this.normalizeFolderId(e.folderId),
|
|
167
167
|
search: e.search || void 0,
|
|
168
168
|
sort_by: e.sortBy,
|
|
169
169
|
sort_order: e.sortOrder,
|
|
170
|
-
limit:
|
|
171
|
-
offset: (s - 1) *
|
|
172
|
-
trashed:
|
|
170
|
+
limit: r,
|
|
171
|
+
offset: (s - 1) * r,
|
|
172
|
+
trashed: t || void 0
|
|
173
173
|
});
|
|
174
174
|
try {
|
|
175
175
|
this.assertOk(a, "folder");
|
|
@@ -178,7 +178,7 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
178
178
|
items: [],
|
|
179
179
|
pagination: {
|
|
180
180
|
page: 1,
|
|
181
|
-
limit:
|
|
181
|
+
limit: r,
|
|
182
182
|
total: 0,
|
|
183
183
|
totalPages: 0,
|
|
184
184
|
hasNext: !1,
|
|
@@ -188,43 +188,43 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
188
188
|
throw i;
|
|
189
189
|
}
|
|
190
190
|
this.onIndexingStateChange?.(!!a.data.indexing);
|
|
191
|
-
const n =
|
|
191
|
+
const n = t ? f.Us : this.normalizeFolderId(e.folderId) ?? this.rootId;
|
|
192
192
|
return {
|
|
193
193
|
items: (a.data.data ?? []).map((i) => this.mapFile(i, n)),
|
|
194
|
-
pagination: this.mapPagination(a.data.page,
|
|
194
|
+
pagination: this.mapPagination(a.data.page, r)
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
-
async createFolder(e,
|
|
198
|
-
const
|
|
197
|
+
async createFolder(e, t) {
|
|
198
|
+
const r = await this.api.folders.foldersCreate({
|
|
199
199
|
project_id: this.projectId,
|
|
200
200
|
name: e,
|
|
201
|
-
parent_id: this.normalizeFolderId(
|
|
201
|
+
parent_id: this.normalizeFolderId(t)
|
|
202
202
|
});
|
|
203
|
-
return this.assertOk(
|
|
203
|
+
return this.assertOk(r), this.mapFolder(r.data.folder ?? {}, t);
|
|
204
204
|
}
|
|
205
|
-
async uploadFileByUrl(e,
|
|
206
|
-
const
|
|
205
|
+
async uploadFileByUrl(e, t) {
|
|
206
|
+
const r = await this.api.files.uploadByUrlCreate({
|
|
207
207
|
project_id: this.projectId,
|
|
208
208
|
url: e,
|
|
209
|
-
folder_id: this.normalizeFolderId(
|
|
209
|
+
folder_id: this.normalizeFolderId(t)
|
|
210
210
|
});
|
|
211
|
-
return this.assertOk(
|
|
211
|
+
return this.assertOk(r), this.mapFile(r.data.file ?? {}, this.normalizeFolderId(t) ?? this.rootId);
|
|
212
212
|
}
|
|
213
213
|
async uploadFiles(e) {
|
|
214
214
|
if (e.items.length === 0) return {
|
|
215
215
|
success: !0,
|
|
216
216
|
detailed: []
|
|
217
217
|
};
|
|
218
|
-
const
|
|
218
|
+
const t = new Map();
|
|
219
219
|
e.items.forEach((a, n) => {
|
|
220
|
-
const i = this.normalizeFolderId(a.folderId ?? e.folderId ?? void 0) ?? this.rootId, o = a.requestId ?? `item-${n}`, p =
|
|
220
|
+
const i = this.normalizeFolderId(a.folderId ?? e.folderId ?? void 0) ?? this.rootId, o = a.requestId ?? `item-${n}`, p = t.get(i) ?? [];
|
|
221
221
|
p.push({
|
|
222
222
|
item: a,
|
|
223
223
|
requestId: o
|
|
224
|
-
}),
|
|
224
|
+
}), t.set(i, p);
|
|
225
225
|
});
|
|
226
|
-
const
|
|
227
|
-
for (const [a, n] of
|
|
226
|
+
const r = [];
|
|
227
|
+
for (const [a, n] of t) {
|
|
228
228
|
const i = new FormData();
|
|
229
229
|
i.append("project_id", this.projectId), a !== this.rootId && i.append("folder_id", a);
|
|
230
230
|
for (const { item: d, requestId: u } of n) i.append("request_id", u), i.append("file", d.data, d.name);
|
|
@@ -239,7 +239,7 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
239
239
|
secure: !0
|
|
240
240
|
}), this.assertOk(o, "file");
|
|
241
241
|
} catch (d) {
|
|
242
|
-
for (const { requestId: u } of n)
|
|
242
|
+
for (const { requestId: u } of n) r.push({
|
|
243
243
|
requestId: u,
|
|
244
244
|
success: !1,
|
|
245
245
|
error: m.toErrorInfo(d)
|
|
@@ -249,42 +249,42 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
249
249
|
const p = new Map((o.data.items ?? []).map((d) => [d.request_id, d]));
|
|
250
250
|
n.forEach(({ requestId: d }, u) => {
|
|
251
251
|
const I = p.get(d) ?? o.data.items?.[u];
|
|
252
|
-
I?.file ?
|
|
252
|
+
I?.file ? r.push({
|
|
253
253
|
requestId: d,
|
|
254
254
|
success: !0,
|
|
255
255
|
data: this.mapFile(I.file, a)
|
|
256
|
-
}) :
|
|
256
|
+
}) : r.push({
|
|
257
257
|
requestId: d,
|
|
258
258
|
success: !1,
|
|
259
259
|
error: this.mapItemFail(I?.error)
|
|
260
260
|
});
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
|
-
const s =
|
|
263
|
+
const s = r.filter((a) => !a.success);
|
|
264
264
|
return {
|
|
265
265
|
success: s.length === 0,
|
|
266
266
|
error: s[0]?.error,
|
|
267
|
-
detailed:
|
|
267
|
+
detailed: r
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
270
|
async uploadFile(e) {
|
|
271
|
-
const
|
|
271
|
+
const t = (await this.uploadFiles({ items: [{
|
|
272
272
|
name: e.name,
|
|
273
273
|
size: e.size,
|
|
274
274
|
type: e.type,
|
|
275
275
|
folderId: e.folderId,
|
|
276
276
|
data: e.data
|
|
277
277
|
}] })).detailed?.[0];
|
|
278
|
-
if (!
|
|
279
|
-
const
|
|
280
|
-
throw
|
|
278
|
+
if (!t?.success || !t.data) {
|
|
279
|
+
const r = t?.error;
|
|
280
|
+
throw r instanceof c ? r : new c(String(r?.message ?? this.i18n.__("Unknown error")), r?.code || "FileWriteError", typeof r?.status == "number" ? r.status : void 0);
|
|
281
281
|
}
|
|
282
|
-
return
|
|
282
|
+
return t.data;
|
|
283
283
|
}
|
|
284
|
-
async updateFile(e,
|
|
285
|
-
let
|
|
286
|
-
if (
|
|
287
|
-
const s = typeof
|
|
284
|
+
async updateFile(e, t) {
|
|
285
|
+
let r = { id: e.id };
|
|
286
|
+
if (t.data !== void 0) {
|
|
287
|
+
const s = typeof t.data == "string" ? m.base64ToBlob(t.data, e.type) : t.data, a = new FormData();
|
|
288
288
|
a.append("project_id", this.projectId), a.append("file", s, e.name);
|
|
289
289
|
const n = await this.api.request({
|
|
290
290
|
path: `/files/${e.id}/content`,
|
|
@@ -296,8 +296,8 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
296
296
|
});
|
|
297
297
|
this.assertOk(n, "file");
|
|
298
298
|
const i = n.data.file ?? {};
|
|
299
|
-
|
|
300
|
-
...
|
|
299
|
+
r = {
|
|
300
|
+
...r,
|
|
301
301
|
size: i.size,
|
|
302
302
|
type: i.mime,
|
|
303
303
|
url: i.url,
|
|
@@ -306,66 +306,66 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
306
306
|
lastEdited: i.updated_at
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
|
-
if (
|
|
310
|
-
const s = await this.renameItem(e,
|
|
311
|
-
|
|
312
|
-
...
|
|
309
|
+
if (t.name && t.name !== e.name) {
|
|
310
|
+
const s = await this.renameItem(e, t.name);
|
|
311
|
+
r = {
|
|
312
|
+
...r,
|
|
313
313
|
...s
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
|
-
return
|
|
316
|
+
return r;
|
|
317
317
|
}
|
|
318
|
-
getFileData = async (e,
|
|
319
|
-
const { __:
|
|
320
|
-
if (!e.url) throw new c(
|
|
318
|
+
getFileData = async (e, t) => {
|
|
319
|
+
const { __: r } = this.i18n;
|
|
320
|
+
if (!e.url) throw new c(r("Failed to get file: %s").replace("%s", e.name), "FileReadError");
|
|
321
321
|
const s = await h.fetchWithResourceProxy(e.url, {
|
|
322
322
|
config: this.appConfig,
|
|
323
323
|
standalone: this.isStandalone,
|
|
324
324
|
resourceType: h.isCdnUrl(e.url, this.appConfig) ? "cdn" : "generic",
|
|
325
325
|
intent: "downloadBlob",
|
|
326
|
-
init:
|
|
326
|
+
init: t?.forceReload ? { cache: "no-store" } : void 0
|
|
327
327
|
});
|
|
328
328
|
if (s.ok) return s.blob();
|
|
329
|
-
throw new c(await s.text() ||
|
|
329
|
+
throw new c(await s.text() || r("Failed to get file: %s").replace("%s", s.statusText), v(s.status), s.status);
|
|
330
330
|
};
|
|
331
|
-
static base64ToBlob(e,
|
|
332
|
-
const
|
|
331
|
+
static base64ToBlob(e, t) {
|
|
332
|
+
const r = e.includes(",") ? e.slice(e.indexOf(",") + 1) : e, s = atob(r), a = new Uint8Array(s.length);
|
|
333
333
|
for (let n = 0; n < s.length; n += 1) a[n] = s.charCodeAt(n);
|
|
334
|
-
return new Blob([a],
|
|
334
|
+
return new Blob([a], t ? { type: t } : void 0);
|
|
335
335
|
}
|
|
336
336
|
mapItemFail(e) {
|
|
337
|
-
const { __:
|
|
337
|
+
const { __: t } = this.i18n;
|
|
338
338
|
return {
|
|
339
|
-
message: e?.message ||
|
|
340
|
-
code: (e?.code ?
|
|
339
|
+
message: e?.message || t("Unknown error"),
|
|
340
|
+
code: (e?.code ? T[e.code] : void 0) ?? "FileWriteError"
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
async renameItem(e,
|
|
343
|
+
async renameItem(e, t) {
|
|
344
344
|
if (e.isFolder) {
|
|
345
345
|
const a = await this.api.folders.foldersPartialUpdate({ id: e.id }, {
|
|
346
346
|
project_id: this.projectId,
|
|
347
|
-
name:
|
|
347
|
+
name: t
|
|
348
348
|
});
|
|
349
349
|
this.assertOk(a, "folder");
|
|
350
350
|
const n = a.data.folder ?? {};
|
|
351
351
|
return {
|
|
352
352
|
id: e.id,
|
|
353
|
-
name: n.name ??
|
|
353
|
+
name: n.name ?? t,
|
|
354
354
|
folderId: n.parent_id ?? e.folderId,
|
|
355
355
|
isFolder: !0,
|
|
356
356
|
lastEdited: n.updated_at
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
|
-
const
|
|
359
|
+
const r = await this.api.files.filesPartialUpdate({ id: e.id }, {
|
|
360
360
|
project_id: this.projectId,
|
|
361
|
-
name:
|
|
361
|
+
name: t,
|
|
362
362
|
mode: "replace"
|
|
363
363
|
});
|
|
364
|
-
this.assertOk(
|
|
365
|
-
const s =
|
|
364
|
+
this.assertOk(r, "file");
|
|
365
|
+
const s = r.data.file ?? {};
|
|
366
366
|
return {
|
|
367
367
|
id: e.id,
|
|
368
|
-
name: s.name ??
|
|
368
|
+
name: s.name ?? t,
|
|
369
369
|
folderId: s.folder_id ?? e.folderId,
|
|
370
370
|
isFolder: !1,
|
|
371
371
|
url: s.url,
|
|
@@ -376,30 +376,30 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
376
376
|
lastEdited: s.updated_at
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
|
-
async deleteItem(e,
|
|
379
|
+
async deleteItem(e, t) {
|
|
380
380
|
try {
|
|
381
381
|
if (e.isFolder) {
|
|
382
|
-
const
|
|
382
|
+
const r = await this.api.folders.foldersDelete({
|
|
383
383
|
id: e.id,
|
|
384
384
|
project_id: this.projectId,
|
|
385
|
-
permanent:
|
|
385
|
+
permanent: t.permanent || void 0
|
|
386
386
|
});
|
|
387
|
-
this.assertOk(
|
|
387
|
+
this.assertOk(r, "folder");
|
|
388
388
|
} else {
|
|
389
|
-
const
|
|
389
|
+
const r = await this.api.files.filesDelete({
|
|
390
390
|
id: e.id,
|
|
391
391
|
project_id: this.projectId,
|
|
392
|
-
permanent:
|
|
392
|
+
permanent: t.permanent || void 0
|
|
393
393
|
});
|
|
394
|
-
this.assertOk(
|
|
394
|
+
this.assertOk(r, "file");
|
|
395
395
|
}
|
|
396
|
-
} catch (
|
|
397
|
-
if (!m.isNotFound(
|
|
396
|
+
} catch (r) {
|
|
397
|
+
if (!m.isNotFound(r)) throw r;
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
async deleteItems(e,
|
|
400
|
+
async deleteItems(e, t) {
|
|
401
401
|
if (e.length === 0) return { success: !0 };
|
|
402
|
-
const
|
|
402
|
+
const r = new Set(e.filter((i) => i.isFolder).map((i) => i.id)), s = new Set(e.filter((i) => r.has(i.folderId))), a = [];
|
|
403
403
|
for (const i of e) {
|
|
404
404
|
if (s.has(i)) {
|
|
405
405
|
a.push({
|
|
@@ -409,7 +409,7 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
409
409
|
continue;
|
|
410
410
|
}
|
|
411
411
|
try {
|
|
412
|
-
await this.deleteItem(i,
|
|
412
|
+
await this.deleteItem(i, t), a.push({
|
|
413
413
|
requestId: i.id,
|
|
414
414
|
success: !0
|
|
415
415
|
});
|
|
@@ -428,26 +428,26 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
428
428
|
detailed: a
|
|
429
429
|
};
|
|
430
430
|
}
|
|
431
|
-
async moveItems(e,
|
|
431
|
+
async moveItems(e, t) {
|
|
432
432
|
if (e.length === 0) return {
|
|
433
433
|
success: !0,
|
|
434
434
|
detailed: []
|
|
435
435
|
};
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
436
|
+
const r = e.filter((i) => i.folderId === f.Us), s = e.filter((i) => i.folderId !== f.Us), a = [];
|
|
437
|
+
if (r.length > 0) {
|
|
438
438
|
const i = await this.api.trash.restoreCreate({
|
|
439
439
|
project_id: this.projectId,
|
|
440
|
-
ids:
|
|
441
|
-
target_folder_id: this.normalizeFolderId(
|
|
440
|
+
ids: r.map((o) => o.id),
|
|
441
|
+
target_folder_id: this.normalizeFolderId(t),
|
|
442
442
|
on_conflict: "keep_both"
|
|
443
443
|
});
|
|
444
|
-
this.assertOk(i), a.push(...this.mapTransferResults(i.data.items,
|
|
444
|
+
this.assertOk(i), a.push(...this.mapTransferResults(i.data.items, r));
|
|
445
445
|
}
|
|
446
446
|
if (s.length > 0) {
|
|
447
447
|
const i = await this.api.items.moveCreate({
|
|
448
448
|
project_id: this.projectId,
|
|
449
449
|
ids: s.map((o) => o.id),
|
|
450
|
-
target_folder_id: this.normalizeFolderId(
|
|
450
|
+
target_folder_id: this.normalizeFolderId(t)
|
|
451
451
|
});
|
|
452
452
|
this.assertOk(i), a.push(...this.mapTransferResults(i.data.items, s));
|
|
453
453
|
}
|
|
@@ -458,29 +458,29 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
458
458
|
detailed: a
|
|
459
459
|
};
|
|
460
460
|
}
|
|
461
|
-
async moveItem(e,
|
|
462
|
-
return this.unwrapSingleTransfer(await this.moveItems([e],
|
|
461
|
+
async moveItem(e, t) {
|
|
462
|
+
return this.unwrapSingleTransfer(await this.moveItems([e], t), e);
|
|
463
463
|
}
|
|
464
|
-
async copyItems(e,
|
|
464
|
+
async copyItems(e, t) {
|
|
465
465
|
if (e.length === 0) return {
|
|
466
466
|
success: !0,
|
|
467
467
|
detailed: []
|
|
468
468
|
};
|
|
469
|
-
const
|
|
469
|
+
const r = await this.api.items.copyCreate({
|
|
470
470
|
project_id: this.projectId,
|
|
471
471
|
ids: e.map((n) => n.id),
|
|
472
|
-
target_folder_id: this.normalizeFolderId(
|
|
472
|
+
target_folder_id: this.normalizeFolderId(t)
|
|
473
473
|
});
|
|
474
|
-
this.assertOk(
|
|
475
|
-
const s = this.mapTransferResults(
|
|
474
|
+
this.assertOk(r);
|
|
475
|
+
const s = this.mapTransferResults(r.data.items, e), a = s.filter((n) => !n.success);
|
|
476
476
|
return {
|
|
477
477
|
success: a.length === 0,
|
|
478
478
|
error: a[0]?.error,
|
|
479
479
|
detailed: s
|
|
480
480
|
};
|
|
481
481
|
}
|
|
482
|
-
async copyItem(e,
|
|
483
|
-
return this.unwrapSingleTransfer(await this.copyItems([e],
|
|
482
|
+
async copyItem(e, t) {
|
|
483
|
+
return this.unwrapSingleTransfer(await this.copyItems([e], t), e);
|
|
484
484
|
}
|
|
485
485
|
async cleanTrash() {
|
|
486
486
|
const e = await this.api.trash.emptyCreate({ project_id: this.projectId });
|
|
@@ -493,25 +493,25 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
493
493
|
findItemByPath(e) {
|
|
494
494
|
return this.resolveSystemFolderByPath(e);
|
|
495
495
|
}
|
|
496
|
-
async findFileByUrl(e,
|
|
497
|
-
const
|
|
496
|
+
async findFileByUrl(e, t) {
|
|
497
|
+
const r = {
|
|
498
498
|
appConfig: this.appConfig,
|
|
499
499
|
isStandalone: this.isStandalone,
|
|
500
500
|
projectId: this.projectId
|
|
501
501
|
};
|
|
502
|
-
if (!
|
|
503
|
-
const s =
|
|
502
|
+
if (!U(e, r)) return;
|
|
503
|
+
const s = A(e, r), a = S.decodeFileNameFromUrl(s);
|
|
504
504
|
if (!a) return;
|
|
505
505
|
const { items: n } = await this.listFiles({
|
|
506
|
-
folderId:
|
|
506
|
+
folderId: t,
|
|
507
507
|
search: a
|
|
508
508
|
}, !1);
|
|
509
509
|
return n.find((i) => i.url === e || i.url === s);
|
|
510
510
|
}
|
|
511
|
-
mapTransferResults(e,
|
|
512
|
-
const
|
|
511
|
+
mapTransferResults(e, t) {
|
|
512
|
+
const r = new Map(t.map((s) => [s.id, s]));
|
|
513
513
|
return (e ?? []).map((s, a) => {
|
|
514
|
-
const n = s.id ??
|
|
514
|
+
const n = s.id ?? t[a]?.id, i = n ? r.get(n) : t[a];
|
|
515
515
|
return s.error ? {
|
|
516
516
|
requestId: n,
|
|
517
517
|
success: !1,
|
|
@@ -523,19 +523,19 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
523
523
|
};
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
|
-
unwrapSingleTransfer(e,
|
|
527
|
-
const
|
|
528
|
-
if (!
|
|
529
|
-
const s =
|
|
526
|
+
unwrapSingleTransfer(e, t) {
|
|
527
|
+
const r = e.detailed?.[0];
|
|
528
|
+
if (!r?.success) {
|
|
529
|
+
const s = r?.error ?? e.error;
|
|
530
530
|
throw s instanceof c ? s : new c(String(s?.message ?? this.i18n.__("Unknown error")), s?.code || "BackendError", typeof s?.status == "number" ? s.status : void 0);
|
|
531
531
|
}
|
|
532
|
-
return
|
|
532
|
+
return r.data ?? { id: t.id };
|
|
533
533
|
}
|
|
534
|
-
mapFile(e,
|
|
534
|
+
mapFile(e, t) {
|
|
535
535
|
return this.trackThumbnailReadiness(e), {
|
|
536
536
|
id: e.id ?? "",
|
|
537
537
|
name: e.name ?? "",
|
|
538
|
-
folderId: e.folder_id ??
|
|
538
|
+
folderId: e.folder_id ?? t,
|
|
539
539
|
isFolder: !1,
|
|
540
540
|
size: e.size,
|
|
541
541
|
date: e.created_at,
|
|
@@ -551,24 +551,30 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
551
551
|
};
|
|
552
552
|
}
|
|
553
553
|
trackThumbnailReadiness(e) {
|
|
554
|
-
!e.id || !e.url || !e.mime?.startsWith("image/")
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const
|
|
560
|
-
|
|
554
|
+
if (!e.id || !e.url || !e.mime?.startsWith("image/")) return;
|
|
555
|
+
if (e.thumbnail_url) {
|
|
556
|
+
this.pendingThumbnails.delete(e.url);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
const t = e.created_at ? new Date(e.created_at).getTime() : NaN;
|
|
560
|
+
Number.isFinite(t) && Date.now() - t < k ? this.pendingThumbnails.set(e.url, e.id) : this.pendingThumbnails.delete(e.url);
|
|
561
|
+
}
|
|
562
|
+
watchThumbnail(e, t) {
|
|
563
|
+
const r = this.pendingThumbnails.get(e);
|
|
564
|
+
if (!r) return () => {};
|
|
565
|
+
const s = this.thumbWatchers.get(r);
|
|
566
|
+
if (s) return s.listeners.add(t), () => s.listeners.delete(t);
|
|
561
567
|
const a = {
|
|
562
|
-
listeners: new Set([
|
|
568
|
+
listeners: new Set([t]),
|
|
563
569
|
cancelled: !1
|
|
564
570
|
};
|
|
565
|
-
return this.thumbWatchers.set(
|
|
566
|
-
a.listeners.delete(
|
|
571
|
+
return this.thumbWatchers.set(r, a), this.pollThumbnail(r, e, a), () => {
|
|
572
|
+
a.listeners.delete(t), a.listeners.size === 0 && (a.cancelled = !0, this.thumbWatchers.delete(r));
|
|
567
573
|
};
|
|
568
574
|
}
|
|
569
|
-
async pollThumbnail(e,
|
|
570
|
-
for (let s = 0; s <
|
|
571
|
-
if (await new Promise((n) => setTimeout(n,
|
|
575
|
+
async pollThumbnail(e, t, r) {
|
|
576
|
+
for (let s = 0; s < b; s += 1) {
|
|
577
|
+
if (await new Promise((n) => setTimeout(n, w)), r.cancelled) return;
|
|
572
578
|
let a;
|
|
573
579
|
try {
|
|
574
580
|
const n = await this.api.files.filesDetail({
|
|
@@ -577,30 +583,30 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
577
583
|
});
|
|
578
584
|
n.ok && !n.error && (a = n.data.file?.thumbnail_url);
|
|
579
585
|
} catch {}
|
|
580
|
-
if (
|
|
586
|
+
if (r.cancelled) return;
|
|
581
587
|
if (a) {
|
|
582
|
-
this.pendingThumbnails.delete(
|
|
588
|
+
this.pendingThumbnails.delete(t), this.thumbWatchers.delete(e), r.listeners.forEach((n) => n(a));
|
|
583
589
|
return;
|
|
584
590
|
}
|
|
585
591
|
}
|
|
586
|
-
this.thumbWatchers.delete(e);
|
|
592
|
+
this.thumbWatchers.delete(e), this.pendingThumbnails.delete(t);
|
|
587
593
|
}
|
|
588
|
-
mapFolder(e,
|
|
594
|
+
mapFolder(e, t) {
|
|
589
595
|
return {
|
|
590
596
|
id: e.id ?? "",
|
|
591
597
|
name: e.name ?? "",
|
|
592
|
-
folderId: e.parent_id ?? this.normalizeFolderId(
|
|
598
|
+
folderId: e.parent_id ?? this.normalizeFolderId(t) ?? this.rootId,
|
|
593
599
|
isFolder: !0,
|
|
594
600
|
date: e.created_at,
|
|
595
601
|
lastEdited: e.updated_at,
|
|
596
602
|
selected: !1
|
|
597
603
|
};
|
|
598
604
|
}
|
|
599
|
-
mapPagination(e,
|
|
600
|
-
const
|
|
605
|
+
mapPagination(e, t) {
|
|
606
|
+
const r = e?.limit ?? t, s = e?.offset ?? 0, a = e?.total ?? 0, n = r > 0 ? Math.floor(s / r) + 1 : 1, i = r > 0 ? Math.ceil(a / r) : 0;
|
|
601
607
|
return {
|
|
602
608
|
page: n,
|
|
603
|
-
limit:
|
|
609
|
+
limit: r,
|
|
604
610
|
total: a,
|
|
605
611
|
totalPages: i,
|
|
606
612
|
hasNext: n < i,
|
|
@@ -610,10 +616,10 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
610
616
|
normalizeFolderId(e) {
|
|
611
617
|
if (!(!e || e === this.rootId)) return e;
|
|
612
618
|
}
|
|
613
|
-
assertOk(e,
|
|
619
|
+
assertOk(e, t) {
|
|
614
620
|
if (e.ok && !e.error) return;
|
|
615
|
-
const { __:
|
|
616
|
-
throw new c(s?.message ||
|
|
621
|
+
const { __: r } = this.i18n, s = e.error?.error, a = (s?.code && t ? O[t][s.code] : void 0) ?? (s?.code ? T[s.code] : void 0) ?? v(e.status);
|
|
622
|
+
throw new c(s?.message || r("Unknown error"), a, e.status);
|
|
617
623
|
}
|
|
618
624
|
static isNotFound(e) {
|
|
619
625
|
return e instanceof c && (e.code === "FileNotFound" || e.code === "FolderNotFound");
|
|
@@ -633,7 +639,7 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
633
639
|
}), Object.defineProperty(F, "FileManagerRestApiProviderV2", {
|
|
634
640
|
enumerable: !0,
|
|
635
641
|
get: function() {
|
|
636
|
-
return
|
|
642
|
+
return x;
|
|
637
643
|
}
|
|
638
644
|
}), Object.defineProperty(F, "arrays", {
|
|
639
645
|
enumerable: !0,
|
|
@@ -643,7 +649,7 @@ __useblocks__.define("static/core/e7c24fe9.js", [
|
|
|
643
649
|
}), Object.defineProperty(F, "hasThumbnailWatcher", {
|
|
644
650
|
enumerable: !0,
|
|
645
651
|
get: function() {
|
|
646
|
-
return
|
|
652
|
+
return M;
|
|
647
653
|
}
|
|
648
654
|
});
|
|
649
655
|
});
|