useblocks 1.1.45 → 1.1.49
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 -0
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.js +1 -1
- package/iframe/js/rules.4N5s3OV-.js +1 -1
- package/monacoeditorwork/css.worker.bundle.js +40524 -40442
- package/monacoeditorwork/editor.worker.bundle.js +9740 -9697
- package/monacoeditorwork/html.worker.bundle.js +50513 -50431
- package/monacoeditorwork/json.worker.bundle.js +14570 -14527
- package/monacoeditorwork/ts.worker.bundle.js +119593 -119455
- package/npm-publish.manifest.json +7 -7
- package/package.json +1 -1
- package/runtime/@ant-design/cssinjs/index.js +1 -1
- package/runtime/@ant-design/icons/index.js +2 -2
- package/runtime/README.md +1 -1
- package/runtime/THIRD_PARTY_LICENSES.txt +70 -42
- package/runtime/antd/index.js +1 -1
- package/runtime/react/index.js +3 -3
- package/runtime/react/jsx-runtime/index.js +1 -1
- package/runtime/react-dom/client/index.js +4 -4
- package/runtime/react-dom/index.js +3 -3
- package/runtime/react-router-dom/index.js +2 -2
- package/singlepage_headless_plugin.html +1 -1
- package/static/core/{cb72ea5e.js → 11296a18.js} +51 -51
- package/static/core/{7d884291.js → 13d197af.js} +20 -20
- package/static/core/13f581cc.js +924 -0
- package/static/core/{6450546e2.js → 1ca5f3772.js} +184 -155
- package/static/core/{af153381.js → 339377b8.js} +15657 -15202
- package/static/core/{94f2c0df.js → 386cf7b3.js} +9673 -9544
- package/static/core/{b7a9d262.js → 3b4845f7.js} +353 -334
- package/static/core/{d14cb6e2.js → 3dea3b87.js} +7 -7
- package/static/core/59023866.js +2090 -0
- package/static/core/{bc098620.js → 7a229b90.js} +3 -3
- package/static/core/{48b80eec.js → 8c81db36.js} +3 -3
- package/static/core/{8c84cc76.js → 8e110c69.js} +24 -24
- package/static/core/{2f2019c1.js → a11c28c2.js} +258 -240
- package/static/core/{fd4fa049.js → aacf134d.js} +745 -664
- package/static/core/{5e0828e3.js → acb049cb.js} +1349 -1297
- package/static/core/{bb774fb9.js → c59f9731.js} +7724 -6646
- package/static/core/{ed0ecf0a.js → de79e0c5.js} +3947 -3705
- package/static/core/e7c24fe9.js +649 -0
- package/static/esm/{dab4cdfd.js → 448d4bb0.js} +70 -70
- package/static/esm/{7c5227f0.js → d180c108.js} +50 -47
- package/static/runtime/{DownloadOutlined-CgJ8OpH_.js → DownloadOutlined-Dg_G2xO7.js} +4 -4
- package/static/runtime/client-CfXgU5Vo.js +7580 -0
- package/static/runtime/{defineProperty-B-FyVNQF.js → defineProperty-C_9hhJHt.js} +1 -1
- package/static/runtime/dom-export-CHgQ7Ws9.js +8069 -0
- package/static/runtime/{es-DnZp8dh1.js → es-BPfImJ0x.js} +5 -5
- package/static/runtime/{es-B2DS-PLP.js → es-DcH6fwd6.js} +2 -2
- package/static/runtime/{es-deqzngIL.js → es-_OY-D9g1.js} +2 -2
- package/static/runtime/{jsx-dev-runtime-Wj1_6O79.js → jsx-dev-runtime-DDukXY54.js} +2 -2
- package/static/runtime/jsx-runtime-BodCQYDg.js +22 -0
- package/static/runtime/react-BHNx_xzv.js +290 -0
- package/static/runtime/react-dom-CyByzibb.js +127 -0
- package/two_step_headless_plugin.html +1 -1
- package/{useblocks-core.ecd1a3b0.js → useblocks-core.15a9129c.js} +82 -76
- package/useblocks-esm.js +628 -3197
- package/useblocks.d.ts +190 -52
- package/useblocks.js +818 -12587
- package/vite/index.cjs +46 -21
- package/vite/index.d.ts +0 -1
- package/vite/index.js +46 -21
- package/vite/pluginDev/index.d.ts +0 -1
- package/webpack/index.cjs +46 -21
- package/webpack/index.d.ts +0 -1
- package/webpack/index.js +46 -21
- package/webpack/pluginDev/index.d.ts +0 -1
- package/iframe/js/amp.CVC2Iq48.js +0 -1
- package/static/core/632d894f.js +0 -869
- package/static/core/c28bc42e.js +0 -46
- package/static/core/ff830d19.js +0 -2046
- package/static/esm/2fb07398.js +0 -3480
- package/static/esm/352121c5.js +0 -55
- package/static/esm/64966e1c.js +0 -18
- package/static/runtime/client-CM3WFcip.js +0 -7
- package/static/runtime/dist-DUS42Hru.js +0 -3421
- package/static/runtime/jsx-runtime-DmPQfqtr.js +0 -28
- package/static/runtime/react-DIf5CLST.js +0 -258
- package/static/runtime/react-dom-Cc3IcUkg.js +0 -5604
- /package/iframe/{iframe-eblock.ecd1a3b0.html → iframe-eblock.15a9129c.html} +0 -0
- /package/iframe/{iframe.ecd1a3b0.html → iframe.15a9129c.html} +0 -0
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
__useblocks__.define("static/core/e7c24fe9.js", [
|
|
2
|
+
"require",
|
|
3
|
+
"exports",
|
|
4
|
+
"module",
|
|
5
|
+
"static/core/c59f9731.js",
|
|
6
|
+
"static/core/13f581cc.js",
|
|
7
|
+
"static/core/acb049cb.js",
|
|
8
|
+
"static/core/386cf7b3.js",
|
|
9
|
+
"static/core/1ca5f3772.js"
|
|
10
|
+
], function(g, F, M) {
|
|
11
|
+
const h = g("./c59f9731.js"), v = g("./13f581cc.js"), E = g("./acb049cb.js"), f = g("./386cf7b3.js");
|
|
12
|
+
g("./1ca5f3772.js");
|
|
13
|
+
var _;
|
|
14
|
+
(function(l) {
|
|
15
|
+
function e(s, a, n = (i, o) => i === o) {
|
|
16
|
+
if (s === a) return !0;
|
|
17
|
+
if (s.length !== a.length) return !1;
|
|
18
|
+
for (let i = 0; i < s.length; i++) if (!n(s[i], a[i])) return !1;
|
|
19
|
+
return !0;
|
|
20
|
+
}
|
|
21
|
+
l.isEqual = e;
|
|
22
|
+
function r(s, a = (n) => n) {
|
|
23
|
+
const n = new Set();
|
|
24
|
+
return s.filter((i) => {
|
|
25
|
+
const o = a(i);
|
|
26
|
+
return n.has(o) ? !1 : (n.add(o), !0);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
l.unique = r;
|
|
30
|
+
function t(s = [], a = [], n = (i, o) => i === o) {
|
|
31
|
+
const i = [], o = [], p = [];
|
|
32
|
+
for (const d of s) {
|
|
33
|
+
const u = a.find((I) => n(d, I));
|
|
34
|
+
u ? p.push({
|
|
35
|
+
prev: d,
|
|
36
|
+
next: u
|
|
37
|
+
}) : o.push(d);
|
|
38
|
+
}
|
|
39
|
+
for (const d of a) s.find((u) => n(d, u)) || i.push(d);
|
|
40
|
+
return {
|
|
41
|
+
added: i,
|
|
42
|
+
removed: o,
|
|
43
|
+
exists: p
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
l.diff = t;
|
|
47
|
+
})(_ || (_ = {}));
|
|
48
|
+
var c = class j extends Error {
|
|
49
|
+
code;
|
|
50
|
+
status;
|
|
51
|
+
details;
|
|
52
|
+
get httpStatus() {
|
|
53
|
+
return this.status;
|
|
54
|
+
}
|
|
55
|
+
constructor(e, r, t, s) {
|
|
56
|
+
super(e), this.name = "FileManagerApiError", this.code = r, this.status = t, this.details = s, Error.captureStackTrace && Error.captureStackTrace(this, j);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
function y(l) {
|
|
60
|
+
return l.replace(/\/+$/, "");
|
|
61
|
+
}
|
|
62
|
+
function S(l, e) {
|
|
63
|
+
const r = y(h.buildCdnFileUrl(e ?? {}, [])), t = y(l);
|
|
64
|
+
if (!(!r || !t.startsWith(`${r}/`))) return t.slice(r.length + 1).split("/").filter(Boolean)[0];
|
|
65
|
+
}
|
|
66
|
+
function P(l, e = {}) {
|
|
67
|
+
const r = e.projectId?.trim();
|
|
68
|
+
if (!r) return !1;
|
|
69
|
+
const t = h.unwrapResourceProxyUrl(l, e.appConfig, e.isStandalone);
|
|
70
|
+
return h.isCdnUrl(t, e.appConfig) ? S(t, e.appConfig) === r : !1;
|
|
71
|
+
}
|
|
72
|
+
function C(l, e = {}) {
|
|
73
|
+
return h.unwrapResourceProxyUrl(l, e.appConfig, e.isStandalone);
|
|
74
|
+
}
|
|
75
|
+
var O = 2e3, k = 30;
|
|
76
|
+
function U(l) {
|
|
77
|
+
return typeof l?.watchThumbnail == "function";
|
|
78
|
+
}
|
|
79
|
+
var w = 200, b = {
|
|
80
|
+
validation_error: "ValidationError",
|
|
81
|
+
unauthorized: "AuthenticationFailed",
|
|
82
|
+
forbidden: "AuthorizationFailed",
|
|
83
|
+
not_found: "FileNotFound",
|
|
84
|
+
conflict: "FolderAlreadyExists",
|
|
85
|
+
payload_too_large: "PayloadTooLarge",
|
|
86
|
+
unsupported_media_type: "FileTypeNotAllowed",
|
|
87
|
+
too_many_requests: "RateLimitExceeded",
|
|
88
|
+
service_unavailable: "ServiceUnavailable",
|
|
89
|
+
internal_error: "BackendError"
|
|
90
|
+
}, x = {
|
|
91
|
+
file: {
|
|
92
|
+
not_found: "FileNotFound",
|
|
93
|
+
conflict: "FileAlreadyExists"
|
|
94
|
+
},
|
|
95
|
+
folder: {
|
|
96
|
+
not_found: "FolderNotFound",
|
|
97
|
+
conflict: "FolderAlreadyExists"
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
function T(l) {
|
|
101
|
+
switch (l) {
|
|
102
|
+
case 400: return "ValidationError";
|
|
103
|
+
case 401: return "AuthenticationFailed";
|
|
104
|
+
case 403: return "AuthorizationFailed";
|
|
105
|
+
case 404: return "FileNotFound";
|
|
106
|
+
case 409: return "FolderAlreadyExists";
|
|
107
|
+
case 413: return "PayloadTooLarge";
|
|
108
|
+
case 415: return "FileTypeNotAllowed";
|
|
109
|
+
case 429: return "RateLimitExceeded";
|
|
110
|
+
case 503: return "ServiceUnavailable";
|
|
111
|
+
case 504: return "Timeout";
|
|
112
|
+
default: return "BackendError";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
var A = class m {
|
|
116
|
+
pathMode = !1;
|
|
117
|
+
rootId = "";
|
|
118
|
+
trashPath = f.Ts;
|
|
119
|
+
useSoftDelete = !1;
|
|
120
|
+
api;
|
|
121
|
+
projectId;
|
|
122
|
+
i18n;
|
|
123
|
+
appConfig;
|
|
124
|
+
isStandalone;
|
|
125
|
+
onIndexingStateChange;
|
|
126
|
+
pendingThumbnails = new Map();
|
|
127
|
+
thumbWatchers = new Map();
|
|
128
|
+
resolveSystemFolderByPath;
|
|
129
|
+
constructor(e) {
|
|
130
|
+
this.api = e.restApi, this.projectId = e.projectId, this.i18n = e.i18n ?? E.defaultI18nContext, this.appConfig = e.appConfig, this.isStandalone = e.isStandalone, this.onIndexingStateChange = e.onIndexingStateChange, this.resolveSystemFolderByPath = f.Us({ Trash: {
|
|
131
|
+
id: f.Ts,
|
|
132
|
+
folderId: this.rootId
|
|
133
|
+
} });
|
|
134
|
+
}
|
|
135
|
+
async getItems(e) {
|
|
136
|
+
const r = e.folderId === f.Ts;
|
|
137
|
+
if (e.itemType === "folder") return { items: await this.listFolders(e.folderId, r) };
|
|
138
|
+
const t = e.itemType === "all" && (e.page ?? 1) <= 1, [s, a] = await Promise.all([t ? this.listFolders(e.folderId, r, e.search) : [], this.listFiles(e, r)]);
|
|
139
|
+
return {
|
|
140
|
+
items: [...s, ...a.items],
|
|
141
|
+
pagination: a.pagination
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async listFolders(e, r, t) {
|
|
145
|
+
const s = await this.api.folders.foldersList({
|
|
146
|
+
project_id: this.projectId,
|
|
147
|
+
parent_id: r ? void 0 : this.normalizeFolderId(e),
|
|
148
|
+
trashed: r || void 0
|
|
149
|
+
});
|
|
150
|
+
try {
|
|
151
|
+
this.assertOk(s, "folder");
|
|
152
|
+
} catch (n) {
|
|
153
|
+
if (m.isNotFound(n)) return [];
|
|
154
|
+
throw n;
|
|
155
|
+
}
|
|
156
|
+
let a = (s.data.items ?? []).map((n) => this.mapFolder(n, e));
|
|
157
|
+
if (t) {
|
|
158
|
+
const n = t.toLowerCase();
|
|
159
|
+
a = a.filter((i) => i.name.toLowerCase().includes(n));
|
|
160
|
+
}
|
|
161
|
+
return a;
|
|
162
|
+
}
|
|
163
|
+
async listFiles(e, r) {
|
|
164
|
+
const t = Math.min(e.limit ?? w, w), s = Math.max(e.page ?? 1, 1), a = await this.api.files.filesList({
|
|
165
|
+
project_id: this.projectId,
|
|
166
|
+
folder_id: r ? void 0 : this.normalizeFolderId(e.folderId),
|
|
167
|
+
search: e.search || void 0,
|
|
168
|
+
sort_by: e.sortBy,
|
|
169
|
+
sort_order: e.sortOrder,
|
|
170
|
+
limit: t,
|
|
171
|
+
offset: (s - 1) * t,
|
|
172
|
+
trashed: r || void 0
|
|
173
|
+
});
|
|
174
|
+
try {
|
|
175
|
+
this.assertOk(a, "folder");
|
|
176
|
+
} catch (i) {
|
|
177
|
+
if (m.isNotFound(i)) return {
|
|
178
|
+
items: [],
|
|
179
|
+
pagination: {
|
|
180
|
+
page: 1,
|
|
181
|
+
limit: t,
|
|
182
|
+
total: 0,
|
|
183
|
+
totalPages: 0,
|
|
184
|
+
hasNext: !1,
|
|
185
|
+
hasPrev: !1
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
throw i;
|
|
189
|
+
}
|
|
190
|
+
this.onIndexingStateChange?.(!!a.data.indexing);
|
|
191
|
+
const n = r ? f.Ts : this.normalizeFolderId(e.folderId) ?? this.rootId;
|
|
192
|
+
return {
|
|
193
|
+
items: (a.data.data ?? []).map((i) => this.mapFile(i, n)),
|
|
194
|
+
pagination: this.mapPagination(a.data.page, t)
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
async createFolder(e, r) {
|
|
198
|
+
const t = await this.api.folders.foldersCreate({
|
|
199
|
+
project_id: this.projectId,
|
|
200
|
+
name: e,
|
|
201
|
+
parent_id: this.normalizeFolderId(r)
|
|
202
|
+
});
|
|
203
|
+
return this.assertOk(t), this.mapFolder(t.data.folder ?? {}, r);
|
|
204
|
+
}
|
|
205
|
+
async uploadFileByUrl(e, r) {
|
|
206
|
+
const t = await this.api.files.uploadByUrlCreate({
|
|
207
|
+
project_id: this.projectId,
|
|
208
|
+
url: e,
|
|
209
|
+
folder_id: this.normalizeFolderId(r)
|
|
210
|
+
});
|
|
211
|
+
return this.assertOk(t), this.mapFile(t.data.file ?? {}, this.normalizeFolderId(r) ?? this.rootId);
|
|
212
|
+
}
|
|
213
|
+
async uploadFiles(e) {
|
|
214
|
+
if (e.items.length === 0) return {
|
|
215
|
+
success: !0,
|
|
216
|
+
detailed: []
|
|
217
|
+
};
|
|
218
|
+
const r = new Map();
|
|
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 = r.get(i) ?? [];
|
|
221
|
+
p.push({
|
|
222
|
+
item: a,
|
|
223
|
+
requestId: o
|
|
224
|
+
}), r.set(i, p);
|
|
225
|
+
});
|
|
226
|
+
const t = [];
|
|
227
|
+
for (const [a, n] of r) {
|
|
228
|
+
const i = new FormData();
|
|
229
|
+
i.append("project_id", this.projectId), a !== this.rootId && i.append("folder_id", a);
|
|
230
|
+
for (const { item: d, requestId: u } of n) i.append("request_id", u), i.append("file", d.data, d.name);
|
|
231
|
+
let o;
|
|
232
|
+
try {
|
|
233
|
+
o = await this.api.request({
|
|
234
|
+
path: "/files",
|
|
235
|
+
method: "POST",
|
|
236
|
+
body: i,
|
|
237
|
+
type: h.ContentType.FormData,
|
|
238
|
+
format: "json",
|
|
239
|
+
secure: !0
|
|
240
|
+
}), this.assertOk(o, "file");
|
|
241
|
+
} catch (d) {
|
|
242
|
+
for (const { requestId: u } of n) t.push({
|
|
243
|
+
requestId: u,
|
|
244
|
+
success: !1,
|
|
245
|
+
error: m.toErrorInfo(d)
|
|
246
|
+
});
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const p = new Map((o.data.items ?? []).map((d) => [d.request_id, d]));
|
|
250
|
+
n.forEach(({ requestId: d }, u) => {
|
|
251
|
+
const I = p.get(d) ?? o.data.items?.[u];
|
|
252
|
+
I?.file ? t.push({
|
|
253
|
+
requestId: d,
|
|
254
|
+
success: !0,
|
|
255
|
+
data: this.mapFile(I.file, a)
|
|
256
|
+
}) : t.push({
|
|
257
|
+
requestId: d,
|
|
258
|
+
success: !1,
|
|
259
|
+
error: this.mapItemFail(I?.error)
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
const s = t.filter((a) => !a.success);
|
|
264
|
+
return {
|
|
265
|
+
success: s.length === 0,
|
|
266
|
+
error: s[0]?.error,
|
|
267
|
+
detailed: t
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
async uploadFile(e) {
|
|
271
|
+
const r = (await this.uploadFiles({ items: [{
|
|
272
|
+
name: e.name,
|
|
273
|
+
size: e.size,
|
|
274
|
+
type: e.type,
|
|
275
|
+
folderId: e.folderId,
|
|
276
|
+
data: e.data
|
|
277
|
+
}] })).detailed?.[0];
|
|
278
|
+
if (!r?.success || !r.data) {
|
|
279
|
+
const t = r?.error;
|
|
280
|
+
throw t instanceof c ? t : new c(String(t?.message ?? this.i18n.__("Unknown error")), t?.code || "FileWriteError", typeof t?.status == "number" ? t.status : void 0);
|
|
281
|
+
}
|
|
282
|
+
return r.data;
|
|
283
|
+
}
|
|
284
|
+
async updateFile(e, r) {
|
|
285
|
+
let t = { id: e.id };
|
|
286
|
+
if (r.data !== void 0) {
|
|
287
|
+
const s = typeof r.data == "string" ? m.base64ToBlob(r.data, e.type) : r.data, a = new FormData();
|
|
288
|
+
a.append("project_id", this.projectId), a.append("file", s, e.name);
|
|
289
|
+
const n = await this.api.request({
|
|
290
|
+
path: `/files/${e.id}/content`,
|
|
291
|
+
method: "PUT",
|
|
292
|
+
body: a,
|
|
293
|
+
type: h.ContentType.FormData,
|
|
294
|
+
format: "json",
|
|
295
|
+
secure: !0
|
|
296
|
+
});
|
|
297
|
+
this.assertOk(n, "file");
|
|
298
|
+
const i = n.data.file ?? {};
|
|
299
|
+
t = {
|
|
300
|
+
...t,
|
|
301
|
+
size: i.size,
|
|
302
|
+
type: i.mime,
|
|
303
|
+
url: i.url,
|
|
304
|
+
thumbnail: i.thumbnail_url,
|
|
305
|
+
thumbnailUrl: i.thumbnail_url,
|
|
306
|
+
lastEdited: i.updated_at
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
if (r.name && r.name !== e.name) {
|
|
310
|
+
const s = await this.renameItem(e, r.name);
|
|
311
|
+
t = {
|
|
312
|
+
...t,
|
|
313
|
+
...s
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
return t;
|
|
317
|
+
}
|
|
318
|
+
getFileData = async (e, r) => {
|
|
319
|
+
const { __: t } = this.i18n;
|
|
320
|
+
if (!e.url) throw new c(t("Failed to get file: %s").replace("%s", e.name), "FileReadError");
|
|
321
|
+
const s = await h.fetchWithResourceProxy(e.url, {
|
|
322
|
+
config: this.appConfig,
|
|
323
|
+
standalone: this.isStandalone,
|
|
324
|
+
resourceType: h.isCdnUrl(e.url, this.appConfig) ? "cdn" : "generic",
|
|
325
|
+
intent: "downloadBlob",
|
|
326
|
+
init: r?.forceReload ? { cache: "no-store" } : void 0
|
|
327
|
+
});
|
|
328
|
+
if (s.ok) return s.blob();
|
|
329
|
+
throw new c(await s.text() || t("Failed to get file: %s").replace("%s", s.statusText), T(s.status), s.status);
|
|
330
|
+
};
|
|
331
|
+
static base64ToBlob(e, r) {
|
|
332
|
+
const t = e.includes(",") ? e.slice(e.indexOf(",") + 1) : e, s = atob(t), a = new Uint8Array(s.length);
|
|
333
|
+
for (let n = 0; n < s.length; n += 1) a[n] = s.charCodeAt(n);
|
|
334
|
+
return new Blob([a], r ? { type: r } : void 0);
|
|
335
|
+
}
|
|
336
|
+
mapItemFail(e) {
|
|
337
|
+
const { __: r } = this.i18n;
|
|
338
|
+
return {
|
|
339
|
+
message: e?.message || r("Unknown error"),
|
|
340
|
+
code: (e?.code ? b[e.code] : void 0) ?? "FileWriteError"
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
async renameItem(e, r) {
|
|
344
|
+
if (e.isFolder) {
|
|
345
|
+
const a = await this.api.folders.foldersPartialUpdate({ id: e.id }, {
|
|
346
|
+
project_id: this.projectId,
|
|
347
|
+
name: r
|
|
348
|
+
});
|
|
349
|
+
this.assertOk(a, "folder");
|
|
350
|
+
const n = a.data.folder ?? {};
|
|
351
|
+
return {
|
|
352
|
+
id: e.id,
|
|
353
|
+
name: n.name ?? r,
|
|
354
|
+
folderId: n.parent_id ?? e.folderId,
|
|
355
|
+
isFolder: !0,
|
|
356
|
+
lastEdited: n.updated_at
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const t = await this.api.files.filesPartialUpdate({ id: e.id }, {
|
|
360
|
+
project_id: this.projectId,
|
|
361
|
+
name: r,
|
|
362
|
+
mode: "replace"
|
|
363
|
+
});
|
|
364
|
+
this.assertOk(t, "file");
|
|
365
|
+
const s = t.data.file ?? {};
|
|
366
|
+
return {
|
|
367
|
+
id: e.id,
|
|
368
|
+
name: s.name ?? r,
|
|
369
|
+
folderId: s.folder_id ?? e.folderId,
|
|
370
|
+
isFolder: !1,
|
|
371
|
+
url: s.url,
|
|
372
|
+
thumbnail: s.thumbnail_url,
|
|
373
|
+
thumbnailUrl: s.thumbnail_url,
|
|
374
|
+
extension: s.ext,
|
|
375
|
+
type: s.mime,
|
|
376
|
+
lastEdited: s.updated_at
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
async deleteItem(e, r) {
|
|
380
|
+
try {
|
|
381
|
+
if (e.isFolder) {
|
|
382
|
+
const t = await this.api.folders.foldersDelete({
|
|
383
|
+
id: e.id,
|
|
384
|
+
project_id: this.projectId,
|
|
385
|
+
permanent: r.permanent || void 0
|
|
386
|
+
});
|
|
387
|
+
this.assertOk(t, "folder");
|
|
388
|
+
} else {
|
|
389
|
+
const t = await this.api.files.filesDelete({
|
|
390
|
+
id: e.id,
|
|
391
|
+
project_id: this.projectId,
|
|
392
|
+
permanent: r.permanent || void 0
|
|
393
|
+
});
|
|
394
|
+
this.assertOk(t, "file");
|
|
395
|
+
}
|
|
396
|
+
} catch (t) {
|
|
397
|
+
if (!m.isNotFound(t)) throw t;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
async deleteItems(e, r) {
|
|
401
|
+
if (e.length === 0) return { success: !0 };
|
|
402
|
+
const t = new Set(e.filter((i) => i.isFolder).map((i) => i.id)), s = new Set(e.filter((i) => t.has(i.folderId))), a = [];
|
|
403
|
+
for (const i of e) {
|
|
404
|
+
if (s.has(i)) {
|
|
405
|
+
a.push({
|
|
406
|
+
requestId: i.id,
|
|
407
|
+
success: !0
|
|
408
|
+
});
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
try {
|
|
412
|
+
await this.deleteItem(i, r), a.push({
|
|
413
|
+
requestId: i.id,
|
|
414
|
+
success: !0
|
|
415
|
+
});
|
|
416
|
+
} catch (o) {
|
|
417
|
+
a.push({
|
|
418
|
+
requestId: i.id,
|
|
419
|
+
success: !1,
|
|
420
|
+
error: m.toErrorInfo(o)
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
const n = a.filter((i) => !i.success);
|
|
425
|
+
return {
|
|
426
|
+
success: n.length === 0,
|
|
427
|
+
error: n[0]?.error,
|
|
428
|
+
detailed: a
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
async moveItems(e, r) {
|
|
432
|
+
if (e.length === 0) return {
|
|
433
|
+
success: !0,
|
|
434
|
+
detailed: []
|
|
435
|
+
};
|
|
436
|
+
const t = e.filter((i) => i.folderId === f.Ts), s = e.filter((i) => i.folderId !== f.Ts), a = [];
|
|
437
|
+
if (t.length > 0) {
|
|
438
|
+
const i = await this.api.trash.restoreCreate({
|
|
439
|
+
project_id: this.projectId,
|
|
440
|
+
ids: t.map((o) => o.id),
|
|
441
|
+
target_folder_id: this.normalizeFolderId(r),
|
|
442
|
+
on_conflict: "keep_both"
|
|
443
|
+
});
|
|
444
|
+
this.assertOk(i), a.push(...this.mapTransferResults(i.data.items, t));
|
|
445
|
+
}
|
|
446
|
+
if (s.length > 0) {
|
|
447
|
+
const i = await this.api.items.moveCreate({
|
|
448
|
+
project_id: this.projectId,
|
|
449
|
+
ids: s.map((o) => o.id),
|
|
450
|
+
target_folder_id: this.normalizeFolderId(r)
|
|
451
|
+
});
|
|
452
|
+
this.assertOk(i), a.push(...this.mapTransferResults(i.data.items, s));
|
|
453
|
+
}
|
|
454
|
+
const n = a.filter((i) => !i.success);
|
|
455
|
+
return {
|
|
456
|
+
success: n.length === 0,
|
|
457
|
+
error: n[0]?.error,
|
|
458
|
+
detailed: a
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
async moveItem(e, r) {
|
|
462
|
+
return this.unwrapSingleTransfer(await this.moveItems([e], r), e);
|
|
463
|
+
}
|
|
464
|
+
async copyItems(e, r) {
|
|
465
|
+
if (e.length === 0) return {
|
|
466
|
+
success: !0,
|
|
467
|
+
detailed: []
|
|
468
|
+
};
|
|
469
|
+
const t = await this.api.items.copyCreate({
|
|
470
|
+
project_id: this.projectId,
|
|
471
|
+
ids: e.map((n) => n.id),
|
|
472
|
+
target_folder_id: this.normalizeFolderId(r)
|
|
473
|
+
});
|
|
474
|
+
this.assertOk(t);
|
|
475
|
+
const s = this.mapTransferResults(t.data.items, e), a = s.filter((n) => !n.success);
|
|
476
|
+
return {
|
|
477
|
+
success: a.length === 0,
|
|
478
|
+
error: a[0]?.error,
|
|
479
|
+
detailed: s
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
async copyItem(e, r) {
|
|
483
|
+
return this.unwrapSingleTransfer(await this.copyItems([e], r), e);
|
|
484
|
+
}
|
|
485
|
+
async cleanTrash() {
|
|
486
|
+
const e = await this.api.trash.emptyCreate({ project_id: this.projectId });
|
|
487
|
+
return this.assertOk(e), {
|
|
488
|
+
success: !0,
|
|
489
|
+
deletedCount: (e.data.deleted_files ?? 0) + (e.data.deleted_folders ?? 0)
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
async clearCache(e) {}
|
|
493
|
+
findItemByPath(e) {
|
|
494
|
+
return this.resolveSystemFolderByPath(e);
|
|
495
|
+
}
|
|
496
|
+
async findFileByUrl(e, r) {
|
|
497
|
+
const t = {
|
|
498
|
+
appConfig: this.appConfig,
|
|
499
|
+
isStandalone: this.isStandalone,
|
|
500
|
+
projectId: this.projectId
|
|
501
|
+
};
|
|
502
|
+
if (!P(e, t)) return;
|
|
503
|
+
const s = C(e, t), a = v.decodeFileNameFromUrl(s);
|
|
504
|
+
if (!a) return;
|
|
505
|
+
const { items: n } = await this.listFiles({
|
|
506
|
+
folderId: r,
|
|
507
|
+
search: a
|
|
508
|
+
}, !1);
|
|
509
|
+
return n.find((i) => i.url === e || i.url === s);
|
|
510
|
+
}
|
|
511
|
+
mapTransferResults(e, r) {
|
|
512
|
+
const t = new Map(r.map((s) => [s.id, s]));
|
|
513
|
+
return (e ?? []).map((s, a) => {
|
|
514
|
+
const n = s.id ?? r[a]?.id, i = n ? t.get(n) : r[a];
|
|
515
|
+
return s.error ? {
|
|
516
|
+
requestId: n,
|
|
517
|
+
success: !1,
|
|
518
|
+
error: this.mapItemFail(s.error)
|
|
519
|
+
} : {
|
|
520
|
+
requestId: n,
|
|
521
|
+
success: !0,
|
|
522
|
+
data: s.file ? this.mapFile(s.file, s.file.folder_id ?? this.rootId) : s.folder ? this.mapFolder(s.folder) : i ? { id: i.id } : { id: n ?? "" }
|
|
523
|
+
};
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
unwrapSingleTransfer(e, r) {
|
|
527
|
+
const t = e.detailed?.[0];
|
|
528
|
+
if (!t?.success) {
|
|
529
|
+
const s = t?.error ?? e.error;
|
|
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
|
+
}
|
|
532
|
+
return t.data ?? { id: r.id };
|
|
533
|
+
}
|
|
534
|
+
mapFile(e, r) {
|
|
535
|
+
return this.trackThumbnailReadiness(e), {
|
|
536
|
+
id: e.id ?? "",
|
|
537
|
+
name: e.name ?? "",
|
|
538
|
+
folderId: e.folder_id ?? r,
|
|
539
|
+
isFolder: !1,
|
|
540
|
+
size: e.size,
|
|
541
|
+
date: e.created_at,
|
|
542
|
+
lastEdited: e.updated_at,
|
|
543
|
+
type: e.mime,
|
|
544
|
+
extension: e.ext,
|
|
545
|
+
url: e.url,
|
|
546
|
+
thumbnail: e.thumbnail_url,
|
|
547
|
+
thumbnailUrl: e.thumbnail_url,
|
|
548
|
+
dimensions: e.width && e.height ? `${e.width}x${e.height}` : void 0,
|
|
549
|
+
aspectRatio: e.width && e.height ? String(e.width / e.height) : void 0,
|
|
550
|
+
selected: !1
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
trackThumbnailReadiness(e) {
|
|
554
|
+
!e.id || !e.url || !e.mime?.startsWith("image/") || (e.thumbnail_url ? this.pendingThumbnails.delete(e.url) : this.pendingThumbnails.set(e.url, e.id));
|
|
555
|
+
}
|
|
556
|
+
watchThumbnail(e, r) {
|
|
557
|
+
const t = this.pendingThumbnails.get(e);
|
|
558
|
+
if (!t) return () => {};
|
|
559
|
+
const s = this.thumbWatchers.get(t);
|
|
560
|
+
if (s) return s.listeners.add(r), () => s.listeners.delete(r);
|
|
561
|
+
const a = {
|
|
562
|
+
listeners: new Set([r]),
|
|
563
|
+
cancelled: !1
|
|
564
|
+
};
|
|
565
|
+
return this.thumbWatchers.set(t, a), this.pollThumbnail(t, e, a), () => {
|
|
566
|
+
a.listeners.delete(r), a.listeners.size === 0 && (a.cancelled = !0, this.thumbWatchers.delete(t));
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
async pollThumbnail(e, r, t) {
|
|
570
|
+
for (let s = 0; s < k; s += 1) {
|
|
571
|
+
if (await new Promise((n) => setTimeout(n, O)), t.cancelled) return;
|
|
572
|
+
let a;
|
|
573
|
+
try {
|
|
574
|
+
const n = await this.api.files.filesDetail({
|
|
575
|
+
id: e,
|
|
576
|
+
project_id: this.projectId
|
|
577
|
+
});
|
|
578
|
+
n.ok && !n.error && (a = n.data.file?.thumbnail_url);
|
|
579
|
+
} catch {}
|
|
580
|
+
if (t.cancelled) return;
|
|
581
|
+
if (a) {
|
|
582
|
+
this.pendingThumbnails.delete(r), this.thumbWatchers.delete(e), t.listeners.forEach((n) => n(a));
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
this.thumbWatchers.delete(e);
|
|
587
|
+
}
|
|
588
|
+
mapFolder(e, r) {
|
|
589
|
+
return {
|
|
590
|
+
id: e.id ?? "",
|
|
591
|
+
name: e.name ?? "",
|
|
592
|
+
folderId: e.parent_id ?? this.normalizeFolderId(r) ?? this.rootId,
|
|
593
|
+
isFolder: !0,
|
|
594
|
+
date: e.created_at,
|
|
595
|
+
lastEdited: e.updated_at,
|
|
596
|
+
selected: !1
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
mapPagination(e, r) {
|
|
600
|
+
const t = e?.limit ?? r, s = e?.offset ?? 0, a = e?.total ?? 0, n = t > 0 ? Math.floor(s / t) + 1 : 1, i = t > 0 ? Math.ceil(a / t) : 0;
|
|
601
|
+
return {
|
|
602
|
+
page: n,
|
|
603
|
+
limit: t,
|
|
604
|
+
total: a,
|
|
605
|
+
totalPages: i,
|
|
606
|
+
hasNext: n < i,
|
|
607
|
+
hasPrev: n > 1
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
normalizeFolderId(e) {
|
|
611
|
+
if (!(!e || e === this.rootId)) return e;
|
|
612
|
+
}
|
|
613
|
+
assertOk(e, r) {
|
|
614
|
+
if (e.ok && !e.error) return;
|
|
615
|
+
const { __: t } = this.i18n, s = e.error?.error, a = (s?.code && r ? x[r][s.code] : void 0) ?? (s?.code ? b[s.code] : void 0) ?? T(e.status);
|
|
616
|
+
throw new c(s?.message || t("Unknown error"), a, e.status);
|
|
617
|
+
}
|
|
618
|
+
static isNotFound(e) {
|
|
619
|
+
return e instanceof c && (e.code === "FileNotFound" || e.code === "FolderNotFound");
|
|
620
|
+
}
|
|
621
|
+
static toErrorInfo(e) {
|
|
622
|
+
return e instanceof c || e instanceof Error ? e : {
|
|
623
|
+
message: String(e),
|
|
624
|
+
raw: e
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
Object.defineProperty(F, "FileManagerApiError", {
|
|
629
|
+
enumerable: !0,
|
|
630
|
+
get: function() {
|
|
631
|
+
return c;
|
|
632
|
+
}
|
|
633
|
+
}), Object.defineProperty(F, "FileManagerRestApiProviderV2", {
|
|
634
|
+
enumerable: !0,
|
|
635
|
+
get: function() {
|
|
636
|
+
return A;
|
|
637
|
+
}
|
|
638
|
+
}), Object.defineProperty(F, "arrays", {
|
|
639
|
+
enumerable: !0,
|
|
640
|
+
get: function() {
|
|
641
|
+
return _;
|
|
642
|
+
}
|
|
643
|
+
}), Object.defineProperty(F, "hasThumbnailWatcher", {
|
|
644
|
+
enumerable: !0,
|
|
645
|
+
get: function() {
|
|
646
|
+
return U;
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
});
|