dexie-cloud-addon 4.1.0-beta.40 → 4.1.0-beta.42

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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.1.0-beta.40, Mon Jan 20 2025
11
+ * Version 4.1.0-beta.42, Tue Feb 04 2025
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -3038,19 +3038,25 @@
3038
3038
  }
3039
3039
  }
3040
3040
 
3041
+ const hasArrayBufferB64 = "fromBase64" in Uint8Array; // https://github.com/tc39/proposal-arraybuffer-base64;
3041
3042
  const b64decode = typeof Buffer !== "undefined"
3042
- ? (base64) => Buffer.from(base64, "base64")
3043
- : (base64) => {
3044
- const binary_string = atob(base64);
3045
- const len = binary_string.length;
3046
- const bytes = new Uint8Array(len);
3047
- for (var i = 0; i < len; i++) {
3048
- bytes[i] = binary_string.charCodeAt(i);
3049
- }
3050
- return bytes;
3051
- };
3043
+ ? (base64) => Buffer.from(base64, "base64") // Node
3044
+ : hasArrayBufferB64
3045
+ ? // @ts-ignore: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64
3046
+ (base64) => Uint8Array.fromBase64(base64) // Modern javascript standard
3047
+ : (base64) => {
3048
+ // Legacy DOM workaround
3049
+ const binary_string = atob(base64);
3050
+ const len = binary_string.length;
3051
+ const bytes = new Uint8Array(len);
3052
+ for (var i = 0; i < len; i++) {
3053
+ bytes[i] = binary_string.charCodeAt(i);
3054
+ }
3055
+ return bytes;
3056
+ };
3052
3057
  const b64encode = typeof Buffer !== "undefined"
3053
3058
  ? (b) => {
3059
+ // Node
3054
3060
  if (ArrayBuffer.isView(b)) {
3055
3061
  return Buffer.from(b.buffer, b.byteOffset, b.byteLength).toString("base64");
3056
3062
  }
@@ -3058,16 +3064,20 @@
3058
3064
  return Buffer.from(b).toString("base64");
3059
3065
  }
3060
3066
  }
3061
- : (b) => {
3062
- const u8a = ArrayBuffer.isView(b) ? b : new Uint8Array(b);
3063
- const CHUNK_SIZE = 0x1000;
3064
- const strs = [];
3065
- for (let i = 0, l = u8a.length; i < l; i += CHUNK_SIZE) {
3066
- const chunk = u8a.subarray(i, i + CHUNK_SIZE);
3067
- strs.push(String.fromCharCode.apply(null, chunk));
3068
- }
3069
- return btoa(strs.join(""));
3070
- };
3067
+ : hasArrayBufferB64
3068
+ ? // @ts-ignore https://github.com/tc39/proposal-arraybuffer-base64
3069
+ (b) => b.toBase64() // Modern Javascript standard
3070
+ : (b) => {
3071
+ // Legacy DOM workaround
3072
+ const u8a = ArrayBuffer.isView(b) ? b : new Uint8Array(b);
3073
+ const CHUNK_SIZE = 0x1000;
3074
+ const strs = [];
3075
+ for (let i = 0, l = u8a.length; i < l; i += CHUNK_SIZE) {
3076
+ const chunk = u8a.subarray(i, i + CHUNK_SIZE);
3077
+ strs.push(String.fromCharCode.apply(null, chunk));
3078
+ }
3079
+ return btoa(strs.join(""));
3080
+ };
3071
3081
 
3072
3082
  class TokenErrorResponseError extends Error {
3073
3083
  constructor({ title, message, messageCode, messageParams, }) {
@@ -4554,6 +4564,26 @@
4554
4564
  },
4555
4565
  };
4556
4566
 
4567
+ var FileDef = {
4568
+ File: {
4569
+ test: (file, toStringTag) => toStringTag === "File",
4570
+ replace: (file) => ({
4571
+ $t: "File",
4572
+ v: b64encode(string2ArrayBuffer(readBlobSync(file))),
4573
+ type: file.type,
4574
+ name: file.name,
4575
+ lastModified: new Date(file.lastModified).toISOString(),
4576
+ }),
4577
+ revive: ({ type, v, name, lastModified }) => {
4578
+ const ab = b64decode(v);
4579
+ return new File([ab], name, {
4580
+ type,
4581
+ lastModified: new Date(lastModified).getTime(),
4582
+ });
4583
+ },
4584
+ },
4585
+ };
4586
+
4557
4587
  // Since server revisions are stored in bigints, we need to handle clients without
4558
4588
  // bigint support to not fail when serverRevision is passed over to client.
4559
4589
  // We need to not fail when reviving it and we need to somehow store the information.
@@ -4589,7 +4619,7 @@
4589
4619
  revive: ({ v }) => new FakeBigInt(v),
4590
4620
  },
4591
4621
  };
4592
- const defs = Object.assign(Object.assign(Object.assign({}, undefinedDef), bigIntDef), { PropModification: {
4622
+ const defs = Object.assign(Object.assign(Object.assign(Object.assign({}, undefinedDef), bigIntDef), FileDef), { PropModification: {
4593
4623
  test: (val) => val instanceof Dexie.PropModification,
4594
4624
  replace: (propModification) => {
4595
4625
  return Object.assign({ $t: 'PropModification' }, propModification['@@propmod']);
@@ -8324,7 +8354,7 @@
8324
8354
  const syncComplete = new rxjs.Subject();
8325
8355
  dexie.cloud = {
8326
8356
  // @ts-ignore
8327
- version: "4.1.0-beta.40",
8357
+ version: "4.1.0-beta.42",
8328
8358
  options: Object.assign({}, DEFAULT_OPTIONS),
8329
8359
  schema: null,
8330
8360
  get currentUserId() {
@@ -8642,7 +8672,7 @@
8642
8672
  }
8643
8673
  }
8644
8674
  // @ts-ignore
8645
- dexieCloud.version = "4.1.0-beta.40";
8675
+ dexieCloud.version = "4.1.0-beta.42";
8646
8676
  Dexie.Cloud = dexieCloud;
8647
8677
 
8648
8678
  exports.default = dexieCloud;