openxiangda 1.0.102 → 1.0.103
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 +12 -0
- package/package.json +1 -1
- package/packages/sdk/dist/components/index.cjs +30 -5
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.d.mts +2 -2
- package/packages/sdk/dist/components/index.d.ts +2 -2
- package/packages/sdk/dist/components/index.mjs +30 -5
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/index.cjs +30 -5
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +1 -1
- package/packages/sdk/dist/runtime/index.d.ts +1 -1
- package/packages/sdk/dist/runtime/index.mjs +30 -5
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/{types-U26h_FIh.d.mts → types-B1GRkvLM.d.mts} +3 -0
- package/packages/sdk/dist/{types-U26h_FIh.d.ts → types-B1GRkvLM.d.ts} +3 -0
|
@@ -5243,6 +5243,7 @@ var import_antd39 = require("antd");
|
|
|
5243
5243
|
init_cjs_shims();
|
|
5244
5244
|
var DEFAULT_CHUNK_SIZE = 5 * 1024 * 1024;
|
|
5245
5245
|
var CHUNK_UPLOAD_THRESHOLD = 10 * 1024 * 1024;
|
|
5246
|
+
var DEFAULT_PUBLIC_FILE_BUCKET = "public-assets";
|
|
5246
5247
|
var trimTrailingSlash2 = (value) => String(value || "").replace(/\/$/, "");
|
|
5247
5248
|
var getDefaultBaseUrl = () => {
|
|
5248
5249
|
const globalEnv = globalThis.process?.env;
|
|
@@ -5289,6 +5290,7 @@ var normalizeFilePayloadUrls = (baseUrl, payload) => {
|
|
|
5289
5290
|
...payload,
|
|
5290
5291
|
url: normalizeRuntimeFileUrl(baseUrl, payload.url),
|
|
5291
5292
|
downloadUrl: normalizeRuntimeFileUrl(baseUrl, payload.downloadUrl),
|
|
5293
|
+
publicUrl: normalizeRuntimeFileUrl(baseUrl, payload.publicUrl),
|
|
5292
5294
|
relayUrl: normalizeRuntimeFileUrl(baseUrl, payload.relayUrl),
|
|
5293
5295
|
previewUrl: normalizeRuntimeFileUrl(baseUrl, payload.previewUrl),
|
|
5294
5296
|
metadataUrl: normalizeRuntimeFileUrl(baseUrl, payload.metadataUrl),
|
|
@@ -5384,6 +5386,8 @@ var normalizeUploadData = (data, file, bucketName, baseUrl = "") => {
|
|
|
5384
5386
|
url: normalizeRuntimeFileUrl(baseUrl, item?.url) || "",
|
|
5385
5387
|
downloadUrl: normalizeRuntimeFileUrl(baseUrl, item?.downloadUrl),
|
|
5386
5388
|
previewUrl: normalizeRuntimeFileUrl(baseUrl, item?.previewUrl),
|
|
5389
|
+
publicUrl: normalizeRuntimeFileUrl(baseUrl, item?.publicUrl),
|
|
5390
|
+
visibility: item?.visibility,
|
|
5387
5391
|
status: "done",
|
|
5388
5392
|
size: item?.size ?? file.size,
|
|
5389
5393
|
objectName,
|
|
@@ -5392,7 +5396,7 @@ var normalizeUploadData = (data, file, bucketName, baseUrl = "") => {
|
|
|
5392
5396
|
mimeType: item?.contentType || file.type
|
|
5393
5397
|
};
|
|
5394
5398
|
};
|
|
5395
|
-
var uploadWithXhr = (baseUrl, file, bucketName, onProgress) => new Promise((resolve, reject) => {
|
|
5399
|
+
var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}) => new Promise((resolve, reject) => {
|
|
5396
5400
|
if (globalThis.process?.env?.VITEST) {
|
|
5397
5401
|
onProgress?.(100);
|
|
5398
5402
|
resolve({
|
|
@@ -5403,14 +5407,24 @@ var uploadWithXhr = (baseUrl, file, bucketName, onProgress) => new Promise((reso
|
|
|
5403
5407
|
status: "done",
|
|
5404
5408
|
size: file.size,
|
|
5405
5409
|
bucketName,
|
|
5406
|
-
contentType: file.type
|
|
5410
|
+
contentType: file.type,
|
|
5411
|
+
visibility: options.visibility
|
|
5407
5412
|
});
|
|
5408
5413
|
return;
|
|
5409
5414
|
}
|
|
5410
5415
|
const xhr = new XMLHttpRequest();
|
|
5411
5416
|
const formData = new FormData();
|
|
5412
5417
|
formData.append("files", file);
|
|
5413
|
-
xhr.open(
|
|
5418
|
+
xhr.open(
|
|
5419
|
+
"POST",
|
|
5420
|
+
joinUrl(
|
|
5421
|
+
baseUrl,
|
|
5422
|
+
appendQuery2("/file/upload", {
|
|
5423
|
+
bucketName,
|
|
5424
|
+
visibility: options.visibility
|
|
5425
|
+
})
|
|
5426
|
+
)
|
|
5427
|
+
);
|
|
5414
5428
|
xhr.withCredentials = true;
|
|
5415
5429
|
const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
|
|
5416
5430
|
if (token) xhr.setRequestHeader("authorization", token);
|
|
@@ -5434,7 +5448,7 @@ var uploadWithXhr = (baseUrl, file, bucketName, onProgress) => new Promise((reso
|
|
|
5434
5448
|
xhr.onerror = () => reject(new Error("\u4E0A\u4F20\u5931\u8D25"));
|
|
5435
5449
|
xhr.send(formData);
|
|
5436
5450
|
});
|
|
5437
|
-
async function uploadChunkedFile(request, file, bucketName, baseUrl, onProgress) {
|
|
5451
|
+
async function uploadChunkedFile(request, file, bucketName, baseUrl, onProgress, options = {}) {
|
|
5438
5452
|
const initiate = await request({
|
|
5439
5453
|
url: "/file/multipart/initiate",
|
|
5440
5454
|
method: "post",
|
|
@@ -5442,7 +5456,8 @@ async function uploadChunkedFile(request, file, bucketName, baseUrl, onProgress)
|
|
|
5442
5456
|
fileName: file.name,
|
|
5443
5457
|
fileSize: file.size,
|
|
5444
5458
|
chunkSize: DEFAULT_CHUNK_SIZE,
|
|
5445
|
-
bucketName
|
|
5459
|
+
bucketName,
|
|
5460
|
+
visibility: options.visibility
|
|
5446
5461
|
}
|
|
5447
5462
|
});
|
|
5448
5463
|
const uploadInfo = initiate.data || initiate.result;
|
|
@@ -5503,6 +5518,16 @@ function createFormRuntimeApi(config3) {
|
|
|
5503
5518
|
}
|
|
5504
5519
|
return uploadWithXhr(baseUrl, file, bucketName, onProgress);
|
|
5505
5520
|
},
|
|
5521
|
+
uploadPublicFile: async (file, bucketName = DEFAULT_PUBLIC_FILE_BUCKET, onProgress) => {
|
|
5522
|
+
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
5523
|
+
return uploadChunkedFile(request, file, bucketName, baseUrl, onProgress, {
|
|
5524
|
+
visibility: "public"
|
|
5525
|
+
});
|
|
5526
|
+
}
|
|
5527
|
+
return uploadWithXhr(baseUrl, file, bucketName, onProgress, {
|
|
5528
|
+
visibility: "public"
|
|
5529
|
+
});
|
|
5530
|
+
},
|
|
5506
5531
|
deleteFile: async (objectName, bucketName = "files") => {
|
|
5507
5532
|
await request({ url: "/file/delete", method: "post", data: { bucketName, objectName } });
|
|
5508
5533
|
return { success: true };
|