@lark-sh/client 0.1.24 → 0.1.26

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.
@@ -337,7 +337,7 @@ function wsUrlToWtUrl(wsUrl) {
337
337
  return url.toString();
338
338
  }
339
339
  async function createTransport(wsUrl, transportOptions, options = {}) {
340
- const preferredType = options.transport || "auto";
340
+ const preferredType = options.transport || "websocket";
341
341
  const shouldTryWebTransport = (preferredType === "auto" || preferredType === "webtransport") && isWebTransportAvailable();
342
342
  if (preferredType === "webtransport" && !isWebTransportAvailable()) {
343
343
  throw new Error("WebTransport is not available in this environment");
@@ -4844,16 +4844,18 @@ var _LarkDatabase = class _LarkDatabase {
4844
4844
  return { o: "u", p: path, v: op.value };
4845
4845
  case "delete":
4846
4846
  return { o: "d", p: path };
4847
- case "condition":
4848
- if (op.value !== void 0 && op.value !== null) {
4849
- validateWriteData(op.value, "transaction condition");
4847
+ case "condition": {
4848
+ const conditionValue = op.value instanceof DataSnapshot ? op.value.exportVal() : op.value;
4849
+ if (conditionValue !== void 0 && conditionValue !== null) {
4850
+ validateWriteData(conditionValue, "transaction condition");
4850
4851
  }
4851
- if (isPrimitive(op.value)) {
4852
- return { o: "c", p: path, v: op.value };
4852
+ if (isPrimitive(conditionValue)) {
4853
+ return { o: "c", p: path, v: conditionValue };
4853
4854
  } else {
4854
- const hash = await hashValue(op.value);
4855
+ const hash = await hashValue(conditionValue);
4855
4856
  return { o: "c", p: path, h: hash };
4856
4857
  }
4858
+ }
4857
4859
  default:
4858
4860
  throw new Error(`Unknown transaction operation: ${op.op}`);
4859
4861
  }
@@ -5008,7 +5010,7 @@ var _LarkDatabase = class _LarkDatabase {
5008
5010
  console.error("Failed to parse message:", data);
5009
5011
  return;
5010
5012
  }
5011
- if (process.env.LARK_DEBUG) {
5013
+ if (typeof process !== "undefined" && process.env?.LARK_DEBUG) {
5012
5014
  console.log("[LARK] <<< SERVER:", JSON.stringify(message, null, 2));
5013
5015
  }
5014
5016
  if (isAckMessage(message)) {
@@ -5074,7 +5076,7 @@ var _LarkDatabase = class _LarkDatabase {
5074
5076
  if (!this.transport || !this.transport.connected) {
5075
5077
  throw new LarkError("not_connected", "Not connected to database");
5076
5078
  }
5077
- if (process.env.LARK_DEBUG) {
5079
+ if (typeof process !== "undefined" && process.env?.LARK_DEBUG) {
5078
5080
  console.log("[LARK] >>> CLIENT:", JSON.stringify(message, null, 2));
5079
5081
  }
5080
5082
  this.transport.send(JSON.stringify(message));