@lark-sh/client 0.1.23 → 0.1.25

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 CHANGED
@@ -13,7 +13,7 @@ JavaScript/TypeScript client for [Lark](https://lark.sh) - a real-time database
13
13
  - **Local-first writes** - Optimistic updates appear instantly
14
14
  - **Works everywhere** - Browsers and Node.js
15
15
  - **TypeScript support** - Full type definitions included
16
- - **~10KB gzipped** - Lightweight bundle
16
+ - **~20KB gzipped** - Lightweight bundle
17
17
 
18
18
  ## Installation
19
19
 
@@ -4799,16 +4799,18 @@ var _LarkDatabase = class _LarkDatabase {
4799
4799
  return { o: "u", p: path, v: op.value };
4800
4800
  case "delete":
4801
4801
  return { o: "d", p: path };
4802
- case "condition":
4803
- if (op.value !== void 0 && op.value !== null) {
4804
- validateWriteData(op.value, "transaction condition");
4802
+ case "condition": {
4803
+ const conditionValue = op.value instanceof DataSnapshot ? op.value.exportVal() : op.value;
4804
+ if (conditionValue !== void 0 && conditionValue !== null) {
4805
+ validateWriteData(conditionValue, "transaction condition");
4805
4806
  }
4806
- if (isPrimitive(op.value)) {
4807
- return { o: "c", p: path, v: op.value };
4807
+ if (isPrimitive(conditionValue)) {
4808
+ return { o: "c", p: path, v: conditionValue };
4808
4809
  } else {
4809
- const hash = await hashValue(op.value);
4810
+ const hash = await hashValue(conditionValue);
4810
4811
  return { o: "c", p: path, h: hash };
4811
4812
  }
4813
+ }
4812
4814
  default:
4813
4815
  throw new Error(`Unknown transaction operation: ${op.op}`);
4814
4816
  }
@@ -4963,7 +4965,7 @@ var _LarkDatabase = class _LarkDatabase {
4963
4965
  console.error("Failed to parse message:", data);
4964
4966
  return;
4965
4967
  }
4966
- if (process.env.LARK_DEBUG) {
4968
+ if (typeof process !== "undefined" && process.env?.LARK_DEBUG) {
4967
4969
  console.log("[LARK] <<< SERVER:", JSON.stringify(message, null, 2));
4968
4970
  }
4969
4971
  if (isAckMessage(message)) {
@@ -5029,7 +5031,7 @@ var _LarkDatabase = class _LarkDatabase {
5029
5031
  if (!this.transport || !this.transport.connected) {
5030
5032
  throw new LarkError("not_connected", "Not connected to database");
5031
5033
  }
5032
- if (process.env.LARK_DEBUG) {
5034
+ if (typeof process !== "undefined" && process.env?.LARK_DEBUG) {
5033
5035
  console.log("[LARK] >>> CLIENT:", JSON.stringify(message, null, 2));
5034
5036
  }
5035
5037
  this.transport.send(JSON.stringify(message));
@@ -5321,8 +5323,8 @@ var _LarkDatabase = class _LarkDatabase {
5321
5323
  */
5322
5324
  _LarkDatabase.ServerValue = ServerValue;
5323
5325
  // Use real timers for ping so fake timers in tests don't cause infinite loops
5324
- _LarkDatabase._realSetInterval = globalThis.setInterval;
5325
- _LarkDatabase._realClearInterval = globalThis.clearInterval;
5326
+ _LarkDatabase._realSetInterval = globalThis.setInterval.bind(globalThis);
5327
+ _LarkDatabase._realClearInterval = globalThis.clearInterval.bind(globalThis);
5326
5328
  var LarkDatabase = _LarkDatabase;
5327
5329
 
5328
5330
  export {
@@ -5337,4 +5339,4 @@ export {
5337
5339
  ServerValue,
5338
5340
  LarkDatabase
5339
5341
  };
5340
- //# sourceMappingURL=chunk-3MBKCYWV.mjs.map
5342
+ //# sourceMappingURL=chunk-LCCMBY4S.mjs.map