@yorkie-js/react 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
  }
@@ -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) {
@@ -19013,7 +19013,7 @@
19013
19013
  };
19014
19014
  }
19015
19015
  const name$1 = "@yorkie-js/sdk";
19016
- const version$1 = "0.6.41-rc";
19016
+ const version$1 = "0.6.41-rc3";
19017
19017
  const pkg$1 = {
19018
19018
  name: name$1,
19019
19019
  version: version$1
@@ -20583,6 +20583,201 @@
20583
20583
  this.processNext();
20584
20584
  }
20585
20585
  }
20586
+ function isText(value) {
20587
+ return typeof value === "object" && value !== null && value.type === "Text" && Array.isArray(value.nodes);
20588
+ }
20589
+ function isTree(value) {
20590
+ return typeof value === "object" && value !== null && value.type === "Tree" && typeof value.root === "object";
20591
+ }
20592
+ function isInt(value) {
20593
+ return typeof value === "object" && value !== null && value.type === "Int" && typeof value.value === "number";
20594
+ }
20595
+ function isLong(value) {
20596
+ return typeof value === "object" && value !== null && value.type === "Long" && typeof value.value === "number";
20597
+ }
20598
+ function isDate(value) {
20599
+ return typeof value === "object" && value !== null && value.type === "Date" && typeof value.value === "string";
20600
+ }
20601
+ function isBinData(value) {
20602
+ return typeof value === "object" && value !== null && value.type === "BinData" && typeof value.value === "string";
20603
+ }
20604
+ function isCounter(value) {
20605
+ return typeof value === "object" && value !== null && value.type === "Counter" && typeof value.value === "object";
20606
+ }
20607
+ function isObject(value) {
20608
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !isText(value) && !isTree(value) && !isInt(value) && !isLong(value) && !isDate(value) && !isBinData(value) && !isCounter(value);
20609
+ }
20610
+ function parse(yson) {
20611
+ try {
20612
+ const processed = preprocessYSON(yson);
20613
+ const parsed = JSON.parse(processed);
20614
+ return postprocessValue(parsed);
20615
+ } catch (err) {
20616
+ throw new YorkieError(
20617
+ Code.ErrInvalidArgument,
20618
+ `Failed to parse YSON: ${err instanceof Error ? err.message : String(err)}`
20619
+ );
20620
+ }
20621
+ }
20622
+ function preprocessYSON(yson) {
20623
+ let result = yson;
20624
+ result = result.replace(
20625
+ /Counter\((Int|Long)\((-?\d+)\)\)/g,
20626
+ (_, type, value) => {
20627
+ return `{"__yson_type":"Counter","__yson_data":{"__yson_type":"${type}","__yson_data":${value}}}`;
20628
+ }
20629
+ );
20630
+ result = result.replace(/Int\((-?\d+)\)/g, (_, value) => {
20631
+ return `{"__yson_type":"Int","__yson_data":${value}}`;
20632
+ });
20633
+ result = result.replace(/Long\((-?\d+)\)/g, (_, value) => {
20634
+ return `{"__yson_type":"Long","__yson_data":${value}}`;
20635
+ });
20636
+ result = result.replace(/Date\("([^"]*)"\)/g, (_, value) => {
20637
+ return `{"__yson_type":"Date","__yson_data":"${value}"}`;
20638
+ });
20639
+ result = result.replace(/BinData\("([^"]*)"\)/g, (_, value) => {
20640
+ return `{"__yson_type":"BinData","__yson_data":"${value}"}`;
20641
+ });
20642
+ result = result.replace(
20643
+ /Text\((\[(?:[^[\]]|\[(?:[^[\]]|\[[^[\]]*\])*\])*\])\)/g,
20644
+ (_, content) => {
20645
+ return `{"__yson_type":"Text","__yson_data":${content}}`;
20646
+ }
20647
+ );
20648
+ result = result.replace(
20649
+ /Tree\((\{[^{}]*(?:\{[^{}]*(?:\{[^{}]*\})*[^{}]*\})*[^{}]*\})\)/g,
20650
+ (_, content) => {
20651
+ return `{"__yson_type":"Tree","__yson_data":${content}}`;
20652
+ }
20653
+ );
20654
+ return result;
20655
+ }
20656
+ function postprocessValue(value) {
20657
+ if (value === null || typeof value !== "object") {
20658
+ return value;
20659
+ }
20660
+ if (value.__yson_type === "Int" && typeof value.__yson_data === "number") {
20661
+ return {
20662
+ type: "Int",
20663
+ value: value.__yson_data
20664
+ };
20665
+ }
20666
+ if (value.__yson_type === "Long" && typeof value.__yson_data === "number") {
20667
+ return {
20668
+ type: "Long",
20669
+ value: value.__yson_data
20670
+ };
20671
+ }
20672
+ if (value.__yson_type === "Date" && typeof value.__yson_data === "string") {
20673
+ return {
20674
+ type: "Date",
20675
+ value: value.__yson_data
20676
+ };
20677
+ }
20678
+ if (value.__yson_type === "BinData" && typeof value.__yson_data === "string") {
20679
+ return {
20680
+ type: "BinData",
20681
+ value: value.__yson_data
20682
+ };
20683
+ }
20684
+ if (value.__yson_type === "Counter" && typeof value.__yson_data === "object") {
20685
+ const counterValue = postprocessValue(value.__yson_data);
20686
+ if (typeof counterValue === "object" && counterValue !== null && "type" in counterValue && (counterValue.type === "Int" || counterValue.type === "Long")) {
20687
+ return {
20688
+ type: "Counter",
20689
+ value: counterValue
20690
+ };
20691
+ }
20692
+ throw new YorkieError(
20693
+ Code.ErrInvalidArgument,
20694
+ "Counter must contain Int or Long"
20695
+ );
20696
+ }
20697
+ if (value.__yson_type === "Text" && Array.isArray(value.__yson_data)) {
20698
+ return {
20699
+ type: "Text",
20700
+ nodes: value.__yson_data.map((node) => postprocessTextNode(node))
20701
+ };
20702
+ }
20703
+ if (value.__yson_type === "Tree" && typeof value.__yson_data === "object") {
20704
+ return {
20705
+ type: "Tree",
20706
+ root: postprocessTreeNode(value.__yson_data)
20707
+ };
20708
+ }
20709
+ if (Array.isArray(value)) {
20710
+ return value.map((item) => postprocessValue(item));
20711
+ }
20712
+ const result = {};
20713
+ for (const [key, val] of Object.entries(value)) {
20714
+ result[key] = postprocessValue(val);
20715
+ }
20716
+ return result;
20717
+ }
20718
+ function postprocessTextNode(node) {
20719
+ if (typeof node !== "object" || node === null || typeof node.val !== "string") {
20720
+ throw new YorkieError(Code.ErrInvalidArgument, "invalid text node format");
20721
+ }
20722
+ const result = { val: node.val };
20723
+ if (node.attrs && typeof node.attrs === "object") {
20724
+ result.attrs = node.attrs;
20725
+ }
20726
+ return result;
20727
+ }
20728
+ function postprocessTreeNode(node) {
20729
+ if (typeof node !== "object" || node === null || typeof node.type !== "string") {
20730
+ throw new YorkieError(Code.ErrInvalidArgument, "invalid tree node format");
20731
+ }
20732
+ const result = { type: node.type };
20733
+ if (node.type === "text" && typeof node.value === "string") {
20734
+ result.value = node.value;
20735
+ return result;
20736
+ }
20737
+ if (node.attrs && typeof node.attrs === "object") {
20738
+ result.attrs = node.attrs;
20739
+ }
20740
+ if (Array.isArray(node.children)) {
20741
+ result.children = node.children.map(
20742
+ (child) => postprocessTreeNode(child)
20743
+ );
20744
+ }
20745
+ return result;
20746
+ }
20747
+ function textToString(text) {
20748
+ return text.nodes.map((node) => node.val).join("");
20749
+ }
20750
+ function treeToXML(tree) {
20751
+ return treeNodeToXML(tree.root);
20752
+ }
20753
+ function treeNodeToXML(node) {
20754
+ const attrs = node.attrs ? Object.entries(node.attrs).map(([key, value]) => ` ${key}="${escapeXML(value)}"`).join("") : "";
20755
+ if (node.type === "text" && node.value !== void 0) {
20756
+ return `<${node.type}${attrs}>${escapeXML(node.value)}</${node.type}>`;
20757
+ }
20758
+ if (!node.children || node.children.length === 0) {
20759
+ return `<${node.type}${attrs} />`;
20760
+ }
20761
+ const children = node.children.map((child) => treeNodeToXML(child)).join("");
20762
+ return `<${node.type}${attrs}>${children}</${node.type}>`;
20763
+ }
20764
+ function escapeXML(str) {
20765
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
20766
+ }
20767
+ const YSON = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
20768
+ __proto__: null,
20769
+ isBinData,
20770
+ isCounter,
20771
+ isDate,
20772
+ isInt,
20773
+ isLong,
20774
+ isObject,
20775
+ isText,
20776
+ isTree,
20777
+ parse,
20778
+ textToString,
20779
+ treeToXML
20780
+ }, Symbol.toStringTag, { value: "Module" }));
20586
20781
  ({
20587
20782
  IntType: CounterType.Int,
20588
20783
  LongType: CounterType.Long
@@ -20597,6 +20792,7 @@
20597
20792
  Tree,
20598
20793
  Channel,
20599
20794
  ChannelEventType,
20795
+ YSON,
20600
20796
  LogLevel,
20601
20797
  setLogLevel,
20602
20798
  IntType: CounterType.Int,
@@ -20604,7 +20800,7 @@
20604
20800
  };
20605
20801
  }
20606
20802
  const name = "@yorkie-js/react";
20607
- const version = "0.6.41-rc";
20803
+ const version = "0.6.41-rc3";
20608
20804
  const pkg = {
20609
20805
  name,
20610
20806
  version