@yorkie-js/sdk 0.6.41-rc → 0.6.41-rc3

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.
@@ -439,12 +439,12 @@
439
439
  }
440
440
  }
441
441
  }
442
- function isObject(arg) {
442
+ function isObject$1(arg) {
443
443
  return arg !== null && typeof arg == "object" && !Array.isArray(arg);
444
444
  }
445
445
  function isReflectList(arg, field) {
446
446
  var _a, _b, _c, _d;
447
- if (isObject(arg) && unsafeLocal in arg && "add" in arg && "field" in arg && typeof arg.field == "function") {
447
+ if (isObject$1(arg) && unsafeLocal in arg && "add" in arg && "field" in arg && typeof arg.field == "function") {
448
448
  if (field !== void 0) {
449
449
  const a = field;
450
450
  const b = arg.field();
@@ -456,7 +456,7 @@
456
456
  }
457
457
  function isReflectMap(arg, field) {
458
458
  var _a, _b, _c, _d;
459
- if (isObject(arg) && unsafeLocal in arg && "has" in arg && "field" in arg && typeof arg.field == "function") {
459
+ if (isObject$1(arg) && unsafeLocal in arg && "has" in arg && "field" in arg && typeof arg.field == "function") {
460
460
  if (field !== void 0) {
461
461
  const a = field, b = arg.field();
462
462
  return a.mapKey === b.mapKey && a.mapKind == b.mapKind && a.scalar === b.scalar && ((_a = a.message) === null || _a === void 0 ? void 0 : _a.typeName) === ((_b = b.message) === null || _b === void 0 ? void 0 : _b.typeName) && ((_c = a.enum) === null || _c === void 0 ? void 0 : _c.typeName) === ((_d = b.enum) === null || _d === void 0 ? void 0 : _d.typeName);
@@ -466,7 +466,7 @@
466
466
  return false;
467
467
  }
468
468
  function isReflectMessage(arg, messageDesc2) {
469
- return isObject(arg) && unsafeLocal in arg && "desc" in arg && isObject(arg.desc) && arg.desc.kind === "message" && (messageDesc2 === void 0 || arg.desc.typeName == messageDesc2.typeName);
469
+ return isObject$1(arg) && unsafeLocal in arg && "desc" in arg && isObject$1(arg.desc) && arg.desc.kind === "message" && (messageDesc2 === void 0 || arg.desc.typeName == messageDesc2.typeName);
470
470
  }
471
471
  function isWrapper(arg) {
472
472
  return isWrapperTypeName(arg.$typeName);
@@ -543,7 +543,7 @@
543
543
  return value;
544
544
  }
545
545
  function initMap(field, value) {
546
- if (isObject(value)) {
546
+ if (isObject$1(value)) {
547
547
  if (field.scalar == ScalarType.BYTES) {
548
548
  return convertObjectValues(value, toU8Arr);
549
549
  }
@@ -568,7 +568,7 @@
568
568
  if (field.fieldKind == "message" && !field.oneof && isWrapperDesc(field.message)) {
569
569
  return initScalar(field.message.fields[0], value);
570
570
  }
571
- if (isObject(value)) {
571
+ if (isObject$1(value)) {
572
572
  if (field.message.typeName == "google.protobuf.Struct" && field.parent.typeName !== "google.protobuf.Value") {
573
573
  return value;
574
574
  }
@@ -1591,7 +1591,7 @@
1591
1591
  $typeName: field.message.typeName,
1592
1592
  value: longToReflect(field.message.fields[0], value)
1593
1593
  };
1594
- } else if (field.message.typeName == "google.protobuf.Struct" && field.parent.typeName != "google.protobuf.Value" && isObject(value)) {
1594
+ } else if (field.message.typeName == "google.protobuf.Struct" && field.parent.typeName != "google.protobuf.Value" && isObject$1(value)) {
1595
1595
  value = wktStructToReflect(value);
1596
1596
  }
1597
1597
  }
@@ -1708,7 +1708,7 @@
1708
1708
  $typeName: "google.protobuf.Struct",
1709
1709
  fields: {}
1710
1710
  };
1711
- if (isObject(json)) {
1711
+ if (isObject$1(json)) {
1712
1712
  for (const [k, v] of Object.entries(json)) {
1713
1713
  struct.fields[k] = wktValueToReflect(v);
1714
1714
  }
@@ -2176,15 +2176,15 @@
2176
2176
  return registry;
2177
2177
  }
2178
2178
  function createBaseRegistry() {
2179
- const types2 = /* @__PURE__ */ new Map();
2179
+ const types = /* @__PURE__ */ new Map();
2180
2180
  const extendees = /* @__PURE__ */ new Map();
2181
2181
  const files = /* @__PURE__ */ new Map();
2182
2182
  return {
2183
2183
  kind: "registry",
2184
- types: types2,
2184
+ types,
2185
2185
  extendees,
2186
2186
  [Symbol.iterator]() {
2187
- return types2.values();
2187
+ return types.values();
2188
2188
  },
2189
2189
  get files() {
2190
2190
  return files.values();
@@ -2214,24 +2214,24 @@
2214
2214
  }
2215
2215
  numberToExt.set(desc.number, desc);
2216
2216
  }
2217
- types2.set(desc.typeName, desc);
2217
+ types.set(desc.typeName, desc);
2218
2218
  },
2219
2219
  get(typeName) {
2220
- return types2.get(typeName);
2220
+ return types.get(typeName);
2221
2221
  },
2222
2222
  getFile(fileName) {
2223
2223
  return files.get(fileName);
2224
2224
  },
2225
2225
  getMessage(typeName) {
2226
- const t = types2.get(typeName);
2226
+ const t = types.get(typeName);
2227
2227
  return (t === null || t === void 0 ? void 0 : t.kind) == "message" ? t : void 0;
2228
2228
  },
2229
2229
  getEnum(typeName) {
2230
- const t = types2.get(typeName);
2230
+ const t = types.get(typeName);
2231
2231
  return (t === null || t === void 0 ? void 0 : t.kind) == "enum" ? t : void 0;
2232
2232
  },
2233
2233
  getExtension(typeName) {
2234
- const t = types2.get(typeName);
2234
+ const t = types.get(typeName);
2235
2235
  return (t === null || t === void 0 ? void 0 : t.kind) == "extension" ? t : void 0;
2236
2236
  },
2237
2237
  getExtensionFor(extendee, no) {
@@ -2239,7 +2239,7 @@
2239
2239
  return (_a = extendees.get(extendee.typeName)) === null || _a === void 0 ? void 0 : _a.get(no);
2240
2240
  },
2241
2241
  getService(typeName) {
2242
- const t = types2.get(typeName);
2242
+ const t = types.get(typeName);
2243
2243
  return (t === null || t === void 0 ? void 0 : t.kind) == "service" ? t : void 0;
2244
2244
  }
2245
2245
  };
@@ -5242,7 +5242,7 @@
5242
5242
  const useBinaryFormat = (_a = options.useBinaryFormat) !== null && _a !== void 0 ? _a : true;
5243
5243
  return {
5244
5244
  async unary(method, signal, timeoutMs, header, message, contextValues) {
5245
- const { serialize, parse } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);
5245
+ const { serialize, parse: parse2 } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);
5246
5246
  timeoutMs = timeoutMs === void 0 ? options.defaultTimeoutMs : timeoutMs <= 0 ? void 0 : timeoutMs;
5247
5247
  return await runUnaryCall({
5248
5248
  interceptors: options.interceptors,
@@ -5290,7 +5290,7 @@
5290
5290
  if (message2 !== void 0) {
5291
5291
  throw new ConnectError("extra message", Code$1.Unimplemented);
5292
5292
  }
5293
- message2 = parse(data);
5293
+ message2 = parse2(data);
5294
5294
  }
5295
5295
  if (trailer === void 0) {
5296
5296
  if (headerError !== void 0)
@@ -5313,7 +5313,7 @@
5313
5313
  });
5314
5314
  },
5315
5315
  async stream(method, signal, timeoutMs, header, input, contextValues) {
5316
- const { serialize, parse } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);
5316
+ const { serialize, parse: parse2 } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);
5317
5317
  function parseResponseBody(body, foundStatus, trailerTarget, header2, signal2) {
5318
5318
  return __asyncGenerator(this, arguments, function* parseResponseBody_1() {
5319
5319
  const reader = createEnvelopeReadableStream(body).getReader();
@@ -5343,7 +5343,7 @@
5343
5343
  if (trailerReceived) {
5344
5344
  throw "extra message";
5345
5345
  }
5346
- yield yield __await(parse(data));
5346
+ yield yield __await(parse2(data));
5347
5347
  }
5348
5348
  if ("throwIfAborted" in signal2) {
5349
5349
  signal2.throwIfAborted();
@@ -6915,14 +6915,14 @@
6915
6915
  }
6916
6916
  Long.prototype.__isLong__;
6917
6917
  Object.defineProperty(Long.prototype, "__isLong__", { value: true });
6918
- function isLong(obj) {
6918
+ function isLong$1(obj) {
6919
6919
  return (obj && obj["__isLong__"]) === true;
6920
6920
  }
6921
6921
  function ctz32(value) {
6922
6922
  var c = Math.clz32(value & -value);
6923
6923
  return value ? 31 - c : c;
6924
6924
  }
6925
- Long.isLong = isLong;
6925
+ Long.isLong = isLong$1;
6926
6926
  var INT_CACHE = {};
6927
6927
  var UINT_CACHE = {};
6928
6928
  function fromInt(value, unsigned) {
@@ -7108,7 +7108,7 @@
7108
7108
  return (this.low & 1) === 0;
7109
7109
  };
7110
7110
  LongPrototype.equals = function equals(other) {
7111
- if (!isLong(other)) other = fromValue(other);
7111
+ if (!isLong$1(other)) other = fromValue(other);
7112
7112
  if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1)
7113
7113
  return false;
7114
7114
  return this.high === other.high && this.low === other.low;
@@ -7153,7 +7153,7 @@
7153
7153
  LongPrototype.gte = LongPrototype.greaterThanOrEqual;
7154
7154
  LongPrototype.ge = LongPrototype.greaterThanOrEqual;
7155
7155
  LongPrototype.compare = function compare(other) {
7156
- if (!isLong(other)) other = fromValue(other);
7156
+ if (!isLong$1(other)) other = fromValue(other);
7157
7157
  if (this.eq(other)) return 0;
7158
7158
  var thisNeg = this.isNegative(), otherNeg = other.isNegative();
7159
7159
  if (thisNeg && !otherNeg) return -1;
@@ -7168,7 +7168,7 @@
7168
7168
  };
7169
7169
  LongPrototype.neg = LongPrototype.negate;
7170
7170
  LongPrototype.add = function add(addend) {
7171
- if (!isLong(addend)) addend = fromValue(addend);
7171
+ if (!isLong$1(addend)) addend = fromValue(addend);
7172
7172
  var a48 = this.high >>> 16;
7173
7173
  var a32 = this.high & 65535;
7174
7174
  var a16 = this.low >>> 16;
@@ -7192,13 +7192,13 @@
7192
7192
  return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
7193
7193
  };
7194
7194
  LongPrototype.subtract = function subtract(subtrahend) {
7195
- if (!isLong(subtrahend)) subtrahend = fromValue(subtrahend);
7195
+ if (!isLong$1(subtrahend)) subtrahend = fromValue(subtrahend);
7196
7196
  return this.add(subtrahend.neg());
7197
7197
  };
7198
7198
  LongPrototype.sub = LongPrototype.subtract;
7199
7199
  LongPrototype.multiply = function multiply(multiplier) {
7200
7200
  if (this.isZero()) return this;
7201
- if (!isLong(multiplier)) multiplier = fromValue(multiplier);
7201
+ if (!isLong$1(multiplier)) multiplier = fromValue(multiplier);
7202
7202
  if (wasm) {
7203
7203
  var low = wasm["mul"](this.low, this.high, multiplier.low, multiplier.high);
7204
7204
  return fromBits(low, wasm["get_high"](), this.unsigned);
@@ -7245,7 +7245,7 @@
7245
7245
  };
7246
7246
  LongPrototype.mul = LongPrototype.multiply;
7247
7247
  LongPrototype.divide = function divide(divisor) {
7248
- if (!isLong(divisor)) divisor = fromValue(divisor);
7248
+ if (!isLong$1(divisor)) divisor = fromValue(divisor);
7249
7249
  if (divisor.isZero()) throw Error("division by zero");
7250
7250
  if (wasm) {
7251
7251
  if (!this.unsigned && this.high === -2147483648 && divisor.low === -1 && divisor.high === -1) {
@@ -7307,7 +7307,7 @@
7307
7307
  };
7308
7308
  LongPrototype.div = LongPrototype.divide;
7309
7309
  LongPrototype.modulo = function modulo(divisor) {
7310
- if (!isLong(divisor)) divisor = fromValue(divisor);
7310
+ if (!isLong$1(divisor)) divisor = fromValue(divisor);
7311
7311
  if (wasm) {
7312
7312
  var low = (this.unsigned ? wasm["rem_u"] : wasm["rem_s"])(
7313
7313
  this.low,
@@ -7333,19 +7333,19 @@
7333
7333
  };
7334
7334
  LongPrototype.ctz = LongPrototype.countTrailingZeros;
7335
7335
  LongPrototype.and = function and(other) {
7336
- if (!isLong(other)) other = fromValue(other);
7336
+ if (!isLong$1(other)) other = fromValue(other);
7337
7337
  return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
7338
7338
  };
7339
7339
  LongPrototype.or = function or(other) {
7340
- if (!isLong(other)) other = fromValue(other);
7340
+ if (!isLong$1(other)) other = fromValue(other);
7341
7341
  return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
7342
7342
  };
7343
7343
  LongPrototype.xor = function xor(other) {
7344
- if (!isLong(other)) other = fromValue(other);
7344
+ if (!isLong$1(other)) other = fromValue(other);
7345
7345
  return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
7346
7346
  };
7347
7347
  LongPrototype.shiftLeft = function shiftLeft(numBits) {
7348
- if (isLong(numBits)) numBits = numBits.toInt();
7348
+ if (isLong$1(numBits)) numBits = numBits.toInt();
7349
7349
  if ((numBits &= 63) === 0) return this;
7350
7350
  else if (numBits < 32)
7351
7351
  return fromBits(
@@ -7357,7 +7357,7 @@
7357
7357
  };
7358
7358
  LongPrototype.shl = LongPrototype.shiftLeft;
7359
7359
  LongPrototype.shiftRight = function shiftRight(numBits) {
7360
- if (isLong(numBits)) numBits = numBits.toInt();
7360
+ if (isLong$1(numBits)) numBits = numBits.toInt();
7361
7361
  if ((numBits &= 63) === 0) return this;
7362
7362
  else if (numBits < 32)
7363
7363
  return fromBits(
@@ -7374,7 +7374,7 @@
7374
7374
  };
7375
7375
  LongPrototype.shr = LongPrototype.shiftRight;
7376
7376
  LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
7377
- if (isLong(numBits)) numBits = numBits.toInt();
7377
+ if (isLong$1(numBits)) numBits = numBits.toInt();
7378
7378
  if ((numBits &= 63) === 0) return this;
7379
7379
  if (numBits < 32)
7380
7380
  return fromBits(
@@ -7389,7 +7389,7 @@
7389
7389
  LongPrototype.shr_u = LongPrototype.shiftRightUnsigned;
7390
7390
  LongPrototype.rotateLeft = function rotateLeft(numBits) {
7391
7391
  var b;
7392
- if (isLong(numBits)) numBits = numBits.toInt();
7392
+ if (isLong$1(numBits)) numBits = numBits.toInt();
7393
7393
  if ((numBits &= 63) === 0) return this;
7394
7394
  if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
7395
7395
  if (numBits < 32) {
@@ -7411,7 +7411,7 @@
7411
7411
  LongPrototype.rotl = LongPrototype.rotateLeft;
7412
7412
  LongPrototype.rotateRight = function rotateRight(numBits) {
7413
7413
  var b;
7414
- if (isLong(numBits)) numBits = numBits.toInt();
7414
+ if (isLong$1(numBits)) numBits = numBits.toInt();
7415
7415
  if ((numBits &= 63) === 0) return this;
7416
7416
  if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
7417
7417
  if (numBits < 32) {
@@ -17693,7 +17693,7 @@
17693
17693
  const EventSourceDevPanel = "yorkie-devtools-panel";
17694
17694
  const EventSourceSDK = "yorkie-devtools-sdk";
17695
17695
  function isDocEventForReplay(event) {
17696
- const types2 = [
17696
+ const types = [
17697
17697
  DocEventType.StatusChanged,
17698
17698
  DocEventType.Snapshot,
17699
17699
  DocEventType.LocalChange,
@@ -17703,12 +17703,12 @@
17703
17703
  DocEventType.Unwatched,
17704
17704
  DocEventType.PresenceChanged
17705
17705
  ];
17706
- return types2.includes(event.type);
17706
+ return types.includes(event.type);
17707
17707
  }
17708
17708
  function isDocEventsForReplay(events) {
17709
17709
  return events.every(isDocEventForReplay);
17710
17710
  }
17711
- const types = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
17711
+ const Devtools = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
17712
17712
  __proto__: null,
17713
17713
  isDocEventForReplay,
17714
17714
  isDocEventsForReplay
@@ -19018,7 +19018,7 @@
19018
19018
  };
19019
19019
  }
19020
19020
  const name = "@yorkie-js/sdk";
19021
- const version = "0.6.41-rc";
19021
+ const version = "0.6.41-rc3";
19022
19022
  const pkg = {
19023
19023
  name,
19024
19024
  version
@@ -20598,6 +20598,201 @@
20598
20598
  this.processNext();
20599
20599
  }
20600
20600
  }
20601
+ function isText(value) {
20602
+ return typeof value === "object" && value !== null && value.type === "Text" && Array.isArray(value.nodes);
20603
+ }
20604
+ function isTree(value) {
20605
+ return typeof value === "object" && value !== null && value.type === "Tree" && typeof value.root === "object";
20606
+ }
20607
+ function isInt(value) {
20608
+ return typeof value === "object" && value !== null && value.type === "Int" && typeof value.value === "number";
20609
+ }
20610
+ function isLong(value) {
20611
+ return typeof value === "object" && value !== null && value.type === "Long" && typeof value.value === "number";
20612
+ }
20613
+ function isDate(value) {
20614
+ return typeof value === "object" && value !== null && value.type === "Date" && typeof value.value === "string";
20615
+ }
20616
+ function isBinData(value) {
20617
+ return typeof value === "object" && value !== null && value.type === "BinData" && typeof value.value === "string";
20618
+ }
20619
+ function isCounter(value) {
20620
+ return typeof value === "object" && value !== null && value.type === "Counter" && typeof value.value === "object";
20621
+ }
20622
+ function isObject(value) {
20623
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !isText(value) && !isTree(value) && !isInt(value) && !isLong(value) && !isDate(value) && !isBinData(value) && !isCounter(value);
20624
+ }
20625
+ function parse(yson) {
20626
+ try {
20627
+ const processed = preprocessYSON(yson);
20628
+ const parsed = JSON.parse(processed);
20629
+ return postprocessValue(parsed);
20630
+ } catch (err) {
20631
+ throw new YorkieError(
20632
+ Code.ErrInvalidArgument,
20633
+ `Failed to parse YSON: ${err instanceof Error ? err.message : String(err)}`
20634
+ );
20635
+ }
20636
+ }
20637
+ function preprocessYSON(yson) {
20638
+ let result = yson;
20639
+ result = result.replace(
20640
+ /Counter\((Int|Long)\((-?\d+)\)\)/g,
20641
+ (_, type, value) => {
20642
+ return `{"__yson_type":"Counter","__yson_data":{"__yson_type":"${type}","__yson_data":${value}}}`;
20643
+ }
20644
+ );
20645
+ result = result.replace(/Int\((-?\d+)\)/g, (_, value) => {
20646
+ return `{"__yson_type":"Int","__yson_data":${value}}`;
20647
+ });
20648
+ result = result.replace(/Long\((-?\d+)\)/g, (_, value) => {
20649
+ return `{"__yson_type":"Long","__yson_data":${value}}`;
20650
+ });
20651
+ result = result.replace(/Date\("([^"]*)"\)/g, (_, value) => {
20652
+ return `{"__yson_type":"Date","__yson_data":"${value}"}`;
20653
+ });
20654
+ result = result.replace(/BinData\("([^"]*)"\)/g, (_, value) => {
20655
+ return `{"__yson_type":"BinData","__yson_data":"${value}"}`;
20656
+ });
20657
+ result = result.replace(
20658
+ /Text\((\[(?:[^[\]]|\[(?:[^[\]]|\[[^[\]]*\])*\])*\])\)/g,
20659
+ (_, content) => {
20660
+ return `{"__yson_type":"Text","__yson_data":${content}}`;
20661
+ }
20662
+ );
20663
+ result = result.replace(
20664
+ /Tree\((\{[^{}]*(?:\{[^{}]*(?:\{[^{}]*\})*[^{}]*\})*[^{}]*\})\)/g,
20665
+ (_, content) => {
20666
+ return `{"__yson_type":"Tree","__yson_data":${content}}`;
20667
+ }
20668
+ );
20669
+ return result;
20670
+ }
20671
+ function postprocessValue(value) {
20672
+ if (value === null || typeof value !== "object") {
20673
+ return value;
20674
+ }
20675
+ if (value.__yson_type === "Int" && typeof value.__yson_data === "number") {
20676
+ return {
20677
+ type: "Int",
20678
+ value: value.__yson_data
20679
+ };
20680
+ }
20681
+ if (value.__yson_type === "Long" && typeof value.__yson_data === "number") {
20682
+ return {
20683
+ type: "Long",
20684
+ value: value.__yson_data
20685
+ };
20686
+ }
20687
+ if (value.__yson_type === "Date" && typeof value.__yson_data === "string") {
20688
+ return {
20689
+ type: "Date",
20690
+ value: value.__yson_data
20691
+ };
20692
+ }
20693
+ if (value.__yson_type === "BinData" && typeof value.__yson_data === "string") {
20694
+ return {
20695
+ type: "BinData",
20696
+ value: value.__yson_data
20697
+ };
20698
+ }
20699
+ if (value.__yson_type === "Counter" && typeof value.__yson_data === "object") {
20700
+ const counterValue = postprocessValue(value.__yson_data);
20701
+ if (typeof counterValue === "object" && counterValue !== null && "type" in counterValue && (counterValue.type === "Int" || counterValue.type === "Long")) {
20702
+ return {
20703
+ type: "Counter",
20704
+ value: counterValue
20705
+ };
20706
+ }
20707
+ throw new YorkieError(
20708
+ Code.ErrInvalidArgument,
20709
+ "Counter must contain Int or Long"
20710
+ );
20711
+ }
20712
+ if (value.__yson_type === "Text" && Array.isArray(value.__yson_data)) {
20713
+ return {
20714
+ type: "Text",
20715
+ nodes: value.__yson_data.map((node) => postprocessTextNode(node))
20716
+ };
20717
+ }
20718
+ if (value.__yson_type === "Tree" && typeof value.__yson_data === "object") {
20719
+ return {
20720
+ type: "Tree",
20721
+ root: postprocessTreeNode(value.__yson_data)
20722
+ };
20723
+ }
20724
+ if (Array.isArray(value)) {
20725
+ return value.map((item) => postprocessValue(item));
20726
+ }
20727
+ const result = {};
20728
+ for (const [key, val] of Object.entries(value)) {
20729
+ result[key] = postprocessValue(val);
20730
+ }
20731
+ return result;
20732
+ }
20733
+ function postprocessTextNode(node) {
20734
+ if (typeof node !== "object" || node === null || typeof node.val !== "string") {
20735
+ throw new YorkieError(Code.ErrInvalidArgument, "invalid text node format");
20736
+ }
20737
+ const result = { val: node.val };
20738
+ if (node.attrs && typeof node.attrs === "object") {
20739
+ result.attrs = node.attrs;
20740
+ }
20741
+ return result;
20742
+ }
20743
+ function postprocessTreeNode(node) {
20744
+ if (typeof node !== "object" || node === null || typeof node.type !== "string") {
20745
+ throw new YorkieError(Code.ErrInvalidArgument, "invalid tree node format");
20746
+ }
20747
+ const result = { type: node.type };
20748
+ if (node.type === "text" && typeof node.value === "string") {
20749
+ result.value = node.value;
20750
+ return result;
20751
+ }
20752
+ if (node.attrs && typeof node.attrs === "object") {
20753
+ result.attrs = node.attrs;
20754
+ }
20755
+ if (Array.isArray(node.children)) {
20756
+ result.children = node.children.map(
20757
+ (child) => postprocessTreeNode(child)
20758
+ );
20759
+ }
20760
+ return result;
20761
+ }
20762
+ function textToString(text) {
20763
+ return text.nodes.map((node) => node.val).join("");
20764
+ }
20765
+ function treeToXML(tree) {
20766
+ return treeNodeToXML(tree.root);
20767
+ }
20768
+ function treeNodeToXML(node) {
20769
+ const attrs = node.attrs ? Object.entries(node.attrs).map(([key, value]) => ` ${key}="${escapeXML(value)}"`).join("") : "";
20770
+ if (node.type === "text" && node.value !== void 0) {
20771
+ return `<${node.type}${attrs}>${escapeXML(node.value)}</${node.type}>`;
20772
+ }
20773
+ if (!node.children || node.children.length === 0) {
20774
+ return `<${node.type}${attrs} />`;
20775
+ }
20776
+ const children = node.children.map((child) => treeNodeToXML(child)).join("");
20777
+ return `<${node.type}${attrs}>${children}</${node.type}>`;
20778
+ }
20779
+ function escapeXML(str) {
20780
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
20781
+ }
20782
+ const YSON = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
20783
+ __proto__: null,
20784
+ isBinData,
20785
+ isCounter,
20786
+ isDate,
20787
+ isInt,
20788
+ isLong,
20789
+ isObject,
20790
+ isText,
20791
+ isTree,
20792
+ parse,
20793
+ textToString,
20794
+ treeToXML
20795
+ }, Symbol.toStringTag, { value: "Module" }));
20601
20796
  const yorkie = {
20602
20797
  Client,
20603
20798
  Document,
@@ -20605,8 +20800,10 @@
20605
20800
  Text,
20606
20801
  Counter,
20607
20802
  Tree,
20803
+ Devtools,
20608
20804
  Channel,
20609
20805
  ChannelEventType,
20806
+ YSON,
20610
20807
  LogLevel,
20611
20808
  setLogLevel,
20612
20809
  IntType: CounterType.Int,
@@ -20622,6 +20819,7 @@
20622
20819
  Tree,
20623
20820
  Channel,
20624
20821
  ChannelEventType,
20822
+ YSON,
20625
20823
  LogLevel,
20626
20824
  setLogLevel,
20627
20825
  IntType: CounterType.Int,
@@ -20637,7 +20835,7 @@
20637
20835
  exports2.ClientStatus = ClientStatus;
20638
20836
  exports2.Counter = Counter;
20639
20837
  exports2.CounterType = CounterType;
20640
- exports2.Devtools = types;
20838
+ exports2.Devtools = Devtools;
20641
20839
  exports2.DocEventType = DocEventType;
20642
20840
  exports2.DocStatus = DocStatus;
20643
20841
  exports2.DocSyncStatus = DocSyncStatus;
@@ -20654,6 +20852,7 @@
20654
20852
  exports2.TimeTicket = TimeTicket;
20655
20853
  exports2.Tree = Tree;
20656
20854
  exports2.VersionVector = VersionVector;
20855
+ exports2.YSON = YSON;
20657
20856
  exports2.converter = converter;
20658
20857
  exports2.default = yorkie;
20659
20858
  exports2.setLogLevel = setLogLevel;