@nexum-hub/browser 1.0.1-next.27 → 1.0.1-next.28

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "packageVersion": "1.0.1-next.27",
2
+ "packageVersion": "1.0.1-next.28",
3
3
  "extensionVersion": "1.0.1",
4
4
  "protocolVersion": 1,
5
5
  "profiles": {
@@ -9,12 +9,17 @@ const chunkBytes = 65536;
9
9
  const nativeBlob = Blob;
10
10
  const blobProbe = new nativeBlob([]);
11
11
  const symbols = Object.getOwnPropertySymbols(blobProbe);
12
+ const bunBlob = "bun" in process.versions;
12
13
  const handleKey = symbols.find((key) => key.description === "kHandle");
13
14
  const sizeKey = symbols.find((key) => key.description === "kLength");
14
15
  const typeKey = symbols.find((key) => key.description === "kType");
15
- const handlePrototype = Object.getPrototypeOf(Object.getOwnPropertyDescriptor(blobProbe, handleKey).value);
16
- const handleSlice = Object.getOwnPropertyDescriptor(handlePrototype, "slice").value;
17
- const handleReader = Object.getOwnPropertyDescriptor(handlePrototype, "getReader").value;
16
+ const handlePrototype = bunBlob ? null : Object.getPrototypeOf(Object.getOwnPropertyDescriptor(blobProbe, handleKey).value);
17
+ const handleSlice = handlePrototype === null ? null
18
+ : Object.getOwnPropertyDescriptor(handlePrototype, "slice").value;
19
+ const handleReader = handlePrototype === null ? null
20
+ : Object.getOwnPropertyDescriptor(handlePrototype, "getReader").value;
21
+ const nativeSize = Object.getOwnPropertyDescriptor(nativeBlob.prototype, "size").get;
22
+ const nativeType = Object.getOwnPropertyDescriptor(nativeBlob.prototype, "type").get;
18
23
  const blobStream = Blob.prototype.stream;
19
24
  const getReader = ReadableStream.prototype.getReader;
20
25
  const typedPrototype = Object.getPrototypeOf(Uint8Array.prototype);
@@ -340,6 +345,24 @@ function blobSnapshot(value, maximum) {
340
345
  }
341
346
  if (!found)
342
347
  return null;
348
+ if (bunBlob) {
349
+ // Bun stores native Blob slots privately, not in Node kHandle Symbols.
350
+ // Its captured intrinsic slice/getters verify the native brand without
351
+ // invoking user-overridden getters or copying uncontrolled source objects.
352
+ let size, type;
353
+ try {
354
+ Reflect.apply(nativeBlob.prototype.slice, value, [0, 0]);
355
+ size = Reflect.apply(nativeSize, value, []);
356
+ type = Reflect.apply(nativeType, value, []);
357
+ }
358
+ catch {
359
+ throw failure("INVALID_ARGUMENT", "The Blob has no native runtime data.");
360
+ }
361
+ check(Number.isSafeInteger(size) && size >= 0 && size <= maximum, "OUTPUT_TOO_LARGE", "Browser file inputs exceed the 128 MiB local protocol budget.");
362
+ check(typeof type === "string" && type.length <= 256 && !/[\r\n\0]/.test(type), "INVALID_ARGUMENT", "Blob MIME metadata must be bounded text.");
363
+ const blob = Reflect.apply(nativeBlob.prototype.slice, value, [0, size, type]);
364
+ return { blob, size, mimeType: Reflect.apply(nativeType, blob, []) };
365
+ }
343
366
  const field = (key) => {
344
367
  const d = Object.getOwnPropertyDescriptor(value, key);
345
368
  check(d && "value" in d, "INVALID_ARGUMENT", "Blob native fields cannot use accessors.");
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@nexum-hub/browser",
3
- "packageVersion": "1.0.1-next.27",
3
+ "packageVersion": "1.0.1-next.28",
4
4
  "status": "in_progress",
5
5
  "published": false,
6
6
  "browserInstallation": "test_profiles_only",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexum-hub/browser",
3
- "version": "1.0.1-next.27",
3
+ "version": "1.0.1-next.28",
4
4
  "private": false,
5
5
  "description": "Nexum 可选浏览器客户端与受管扩展",
6
6
  "type": "module",
@@ -63,7 +63,7 @@
63
63
  "ws": "8.23.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "@nexum-hub/sdk": "1.0.1-next.27"
66
+ "@nexum-hub/sdk": "1.0.1-next.28"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@nexum-hub/sdk": {
@@ -37,9 +37,11 @@ let file;
37
37
  try {
38
38
  file = await downloaded.path();
39
39
  } catch (error) {
40
- if (error?.code !== "CAPABILITY_NOT_ALLOWED" &&
41
- error?.code !== "FILE_UNAVAILABLE") throw error;
42
- return { status: "unconfirmed", code: error.code,
40
+ const code = typeof error === "object" && error !== null && "code" in error
41
+ ? error.code : undefined;
42
+ if (code !== "CAPABILITY_NOT_ALLOWED" &&
43
+ code !== "FILE_UNAVAILABLE") throw error;
44
+ return { status: "unconfirmed", code,
43
45
  reason: "无法可靠确认该下载对应的本地文件;请按当前下载记录核对" };
44
46
  }
45
47
  if (file === null) return { status: "unconfirmed",