dexie-cloud-addon 4.2.1 → 4.2.2

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.2.1, Wed Oct 01 2025
11
+ * Version 4.2.2, Sat Oct 04 2025
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -4284,6 +4284,7 @@ function createMutationTrackingMiddleware({ currentUserObservable, db, }) {
4284
4284
  let values = 'values' in req ? req.values : [];
4285
4285
  let changeSpec = 'changeSpec' in req ? req.changeSpec : undefined;
4286
4286
  let updates = 'updates' in req ? req.updates : undefined;
4287
+ let upsert = updates && 'upsert' in req ? req.upsert : false;
4287
4288
  if (hasFailures) {
4288
4289
  keys = keys.filter((_, idx) => !failures[idx]);
4289
4290
  values = values.filter((_, idx) => !failures[idx]);
@@ -4315,29 +4316,32 @@ function createMutationTrackingMiddleware({ currentUserObservable, db, }) {
4315
4316
  };
4316
4317
  const validKeys = new RangeSet();
4317
4318
  let anyChangeSpecBecameEmpty = false;
4318
- for (let i = 0, l = strippedChangeSpecs.length; i < l; ++i) {
4319
- if (Object.keys(strippedChangeSpecs[i]).length > 0) {
4320
- newUpdates.keys.push(updates.keys[i]);
4321
- newUpdates.changeSpecs.push(strippedChangeSpecs[i]);
4322
- validKeys.addKey(updates.keys[i]);
4323
- }
4324
- else {
4325
- anyChangeSpecBecameEmpty = true;
4319
+ if (!upsert) {
4320
+ for (let i = 0, l = strippedChangeSpecs.length; i < l; ++i) {
4321
+ if (Object.keys(strippedChangeSpecs[i]).length > 0) {
4322
+ newUpdates.keys.push(updates.keys[i]);
4323
+ newUpdates.changeSpecs.push(strippedChangeSpecs[i]);
4324
+ validKeys.addKey(updates.keys[i]);
4325
+ }
4326
+ else {
4327
+ anyChangeSpecBecameEmpty = true;
4328
+ }
4326
4329
  }
4327
- }
4328
- updates = newUpdates;
4329
- if (anyChangeSpecBecameEmpty) {
4330
- // Some keys were stripped. We must also strip them from keys and values
4331
- let newKeys = [];
4332
- let newValues = [];
4333
- for (let i = 0, l = keys.length; i < l; ++i) {
4334
- if (validKeys.hasKey(keys[i])) {
4335
- newKeys.push(keys[i]);
4336
- newValues.push(values[i]);
4330
+ updates = newUpdates;
4331
+ if (anyChangeSpecBecameEmpty) {
4332
+ // Some keys were stripped. We must also strip them from keys and values
4333
+ // unless this is an upsert operation in which case we want to send them all.
4334
+ let newKeys = [];
4335
+ let newValues = [];
4336
+ for (let i = 0, l = keys.length; i < l; ++i) {
4337
+ if (validKeys.hasKey(keys[i])) {
4338
+ newKeys.push(keys[i]);
4339
+ newValues.push(values[i]);
4340
+ }
4337
4341
  }
4342
+ keys = newKeys;
4343
+ values = newValues;
4338
4344
  }
4339
- keys = newKeys;
4340
- values = newValues;
4341
4345
  }
4342
4346
  }
4343
4347
  }
@@ -4379,49 +4383,59 @@ function createMutationTrackingMiddleware({ currentUserObservable, db, }) {
4379
4383
  userId,
4380
4384
  values,
4381
4385
  }
4382
- : criteria && changeSpec
4383
- ? {
4384
- // Common changeSpec for all keys
4385
- type: 'modify',
4386
- ts,
4387
- opNo,
4388
- keys,
4389
- criteria,
4390
- changeSpec,
4391
- txid,
4392
- userId,
4393
- }
4394
- : changeSpec
4386
+ : upsert ? {
4387
+ type: 'upsert',
4388
+ ts,
4389
+ opNo,
4390
+ keys,
4391
+ values,
4392
+ changeSpecs: updates.changeSpecs.filter((_, idx) => !failures[idx]),
4393
+ txid,
4394
+ userId,
4395
+ }
4396
+ : criteria && changeSpec
4395
4397
  ? {
4396
- // In case criteria involved an unsynced property, we go for keys instead.
4397
- type: 'update',
4398
+ // Common changeSpec for all keys
4399
+ type: 'modify',
4398
4400
  ts,
4399
4401
  opNo,
4400
4402
  keys,
4401
- changeSpecs: keys.map(() => changeSpec),
4403
+ criteria,
4404
+ changeSpec,
4402
4405
  txid,
4403
4406
  userId,
4404
4407
  }
4405
- : updates
4408
+ : changeSpec
4406
4409
  ? {
4407
- // One changeSpec per key
4410
+ // In case criteria involved an unsynced property, we go for keys instead.
4408
4411
  type: 'update',
4409
4412
  ts,
4410
4413
  opNo,
4411
- keys: updates.keys,
4412
- changeSpecs: updates.changeSpecs,
4413
- txid,
4414
- userId,
4415
- }
4416
- : {
4417
- type: 'upsert',
4418
- ts,
4419
- opNo,
4420
4414
  keys,
4421
- values,
4415
+ changeSpecs: keys.map(() => changeSpec),
4422
4416
  txid,
4423
4417
  userId,
4424
- };
4418
+ }
4419
+ : updates
4420
+ ? {
4421
+ // One changeSpec per key
4422
+ type: 'update',
4423
+ ts,
4424
+ opNo,
4425
+ keys: updates.keys,
4426
+ changeSpecs: updates.changeSpecs,
4427
+ txid,
4428
+ userId,
4429
+ }
4430
+ : {
4431
+ type: 'upsert',
4432
+ ts,
4433
+ opNo,
4434
+ keys,
4435
+ values,
4436
+ txid,
4437
+ userId,
4438
+ };
4425
4439
  if ('isAdditionalChunk' in req && req.isAdditionalChunk) {
4426
4440
  mut.isAdditionalChunk = true;
4427
4441
  }
@@ -5316,34 +5330,85 @@ const Styles = {
5316
5330
  alignItems: "center",
5317
5331
  display: "flex",
5318
5332
  justifyContent: "center",
5333
+ padding: "16px",
5334
+ boxSizing: "border-box"
5319
5335
  },
5320
5336
  DialogInner: {
5321
5337
  position: "relative",
5322
5338
  color: "#222",
5323
5339
  backgroundColor: "#fff",
5324
- padding: "30px",
5340
+ padding: "24px",
5325
5341
  marginBottom: "2em",
5326
- maxWidth: "90%",
5342
+ maxWidth: "400px",
5343
+ width: "100%",
5327
5344
  maxHeight: "90%",
5328
5345
  overflowY: "auto",
5329
5346
  border: "3px solid #3d3d5d",
5330
5347
  borderRadius: "8px",
5331
5348
  boxShadow: "0 0 80px 10px #666",
5332
- width: "auto",
5333
5349
  fontFamily: "sans-serif",
5350
+ boxSizing: "border-box"
5334
5351
  },
5335
5352
  Input: {
5336
5353
  height: "35px",
5337
- width: "17em",
5354
+ width: "100%",
5355
+ maxWidth: "100%",
5338
5356
  borderColor: "#ccf4",
5339
5357
  outline: "none",
5340
- fontSize: "17pt",
5341
- padding: "8px"
5358
+ fontSize: "16px",
5359
+ padding: "8px",
5360
+ boxSizing: "border-box"
5361
+ },
5362
+ Button: {
5363
+ padding: "10px 20px",
5364
+ margin: "0 4px",
5365
+ border: "1px solid #d1d5db",
5366
+ borderRadius: "6px",
5367
+ backgroundColor: "#ffffff",
5368
+ cursor: "pointer",
5369
+ fontSize: "14px",
5370
+ fontWeight: "500",
5371
+ color: "#374151",
5372
+ transition: "all 0.2s ease"
5373
+ },
5374
+ PrimaryButton: {
5375
+ padding: "10px 20px",
5376
+ margin: "0 4px",
5377
+ border: "1px solid #3b82f6",
5378
+ borderRadius: "6px",
5379
+ backgroundColor: "#3b82f6",
5380
+ color: "white",
5381
+ cursor: "pointer",
5382
+ fontSize: "14px",
5383
+ fontWeight: "500",
5384
+ transition: "all 0.2s ease"
5385
+ },
5386
+ ButtonsDiv: {
5387
+ display: "flex",
5388
+ justifyContent: "flex-end",
5389
+ gap: "12px",
5390
+ marginTop: "24px",
5391
+ paddingTop: "20px"
5392
+ },
5393
+ Label: {
5394
+ display: "block",
5395
+ marginBottom: "12px",
5396
+ fontSize: "14px",
5397
+ fontWeight: "500",
5398
+ color: "#333"
5399
+ },
5400
+ WindowHeader: {
5401
+ margin: "0 0 20px 0",
5402
+ fontSize: "18px",
5403
+ fontWeight: "600",
5404
+ color: "#333",
5405
+ borderBottom: "1px solid #eee",
5406
+ paddingBottom: "10px"
5342
5407
  }
5343
5408
  };
5344
5409
 
5345
5410
  function Dialog({ children, className }) {
5346
- return (h("div", { className: className },
5411
+ return (h("div", { className: `dexie-dialog ${className || ''}` },
5347
5412
  h("div", { style: Styles.Darken }),
5348
5413
  h("div", { style: Styles.DialogOuter },
5349
5414
  h("div", { style: Styles.DialogInner }, children))));
@@ -5395,7 +5460,7 @@ function LoginDialog({ title, type, alerts, fields, submitLabel, cancelLabel, on
5395
5460
  } })))))),
5396
5461
  h("div", { style: Styles.ButtonsDiv },
5397
5462
  h(p$1, null,
5398
- h("button", { type: "submit", style: Styles.Button, onClick: () => onSubmit(params) }, submitLabel),
5463
+ h("button", { type: "submit", style: Styles.PrimaryButton, onClick: () => onSubmit(params) }, submitLabel),
5399
5464
  cancelLabel && (h("button", { style: Styles.Button, onClick: onCancel }, cancelLabel))))));
5400
5465
  }
5401
5466
  function valueTransformer(type, value) {
@@ -6026,7 +6091,7 @@ function dexieCloud(dexie) {
6026
6091
  const syncComplete = new Subject();
6027
6092
  dexie.cloud = {
6028
6093
  // @ts-ignore
6029
- version: "4.2.1",
6094
+ version: "4.2.2",
6030
6095
  options: Object.assign({}, DEFAULT_OPTIONS),
6031
6096
  schema: null,
6032
6097
  get currentUserId() {
@@ -6343,7 +6408,7 @@ function dexieCloud(dexie) {
6343
6408
  }
6344
6409
  }
6345
6410
  // @ts-ignore
6346
- dexieCloud.version = "4.2.1";
6411
+ dexieCloud.version = "4.2.2";
6347
6412
  Dexie.Cloud = dexieCloud;
6348
6413
 
6349
6414
  // In case the SW lives for a while, let it reuse already opened connections: