@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.
- package/dist/yorkie-js-sdk.d.ts +383 -2
- package/dist/yorkie-js-sdk.es.js +242 -43
- package/dist/yorkie-js-sdk.es.js.map +1 -1
- package/dist/yorkie-js-sdk.js +242 -43
- package/dist/yorkie-js-sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/yorkie-js-sdk.es.js
CHANGED
|
@@ -435,12 +435,12 @@ function unsafeClear(target, field) {
|
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
function isObject(arg) {
|
|
438
|
+
function isObject$1(arg) {
|
|
439
439
|
return arg !== null && typeof arg == "object" && !Array.isArray(arg);
|
|
440
440
|
}
|
|
441
441
|
function isReflectList(arg, field) {
|
|
442
442
|
var _a, _b, _c, _d;
|
|
443
|
-
if (isObject(arg) && unsafeLocal in arg && "add" in arg && "field" in arg && typeof arg.field == "function") {
|
|
443
|
+
if (isObject$1(arg) && unsafeLocal in arg && "add" in arg && "field" in arg && typeof arg.field == "function") {
|
|
444
444
|
if (field !== void 0) {
|
|
445
445
|
const a = field;
|
|
446
446
|
const b = arg.field();
|
|
@@ -452,7 +452,7 @@ function isReflectList(arg, field) {
|
|
|
452
452
|
}
|
|
453
453
|
function isReflectMap(arg, field) {
|
|
454
454
|
var _a, _b, _c, _d;
|
|
455
|
-
if (isObject(arg) && unsafeLocal in arg && "has" in arg && "field" in arg && typeof arg.field == "function") {
|
|
455
|
+
if (isObject$1(arg) && unsafeLocal in arg && "has" in arg && "field" in arg && typeof arg.field == "function") {
|
|
456
456
|
if (field !== void 0) {
|
|
457
457
|
const a = field, b = arg.field();
|
|
458
458
|
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);
|
|
@@ -462,7 +462,7 @@ function isReflectMap(arg, field) {
|
|
|
462
462
|
return false;
|
|
463
463
|
}
|
|
464
464
|
function isReflectMessage(arg, messageDesc2) {
|
|
465
|
-
return isObject(arg) && unsafeLocal in arg && "desc" in arg && isObject(arg.desc) && arg.desc.kind === "message" && (messageDesc2 === void 0 || arg.desc.typeName == messageDesc2.typeName);
|
|
465
|
+
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);
|
|
466
466
|
}
|
|
467
467
|
function isWrapper(arg) {
|
|
468
468
|
return isWrapperTypeName(arg.$typeName);
|
|
@@ -539,7 +539,7 @@ function initScalar(field, value) {
|
|
|
539
539
|
return value;
|
|
540
540
|
}
|
|
541
541
|
function initMap(field, value) {
|
|
542
|
-
if (isObject(value)) {
|
|
542
|
+
if (isObject$1(value)) {
|
|
543
543
|
if (field.scalar == ScalarType.BYTES) {
|
|
544
544
|
return convertObjectValues(value, toU8Arr);
|
|
545
545
|
}
|
|
@@ -564,7 +564,7 @@ function toMessage(field, value) {
|
|
|
564
564
|
if (field.fieldKind == "message" && !field.oneof && isWrapperDesc(field.message)) {
|
|
565
565
|
return initScalar(field.message.fields[0], value);
|
|
566
566
|
}
|
|
567
|
-
if (isObject(value)) {
|
|
567
|
+
if (isObject$1(value)) {
|
|
568
568
|
if (field.message.typeName == "google.protobuf.Struct" && field.parent.typeName !== "google.protobuf.Value") {
|
|
569
569
|
return value;
|
|
570
570
|
}
|
|
@@ -1587,7 +1587,7 @@ function messageToReflect(field, value, check) {
|
|
|
1587
1587
|
$typeName: field.message.typeName,
|
|
1588
1588
|
value: longToReflect(field.message.fields[0], value)
|
|
1589
1589
|
};
|
|
1590
|
-
} else if (field.message.typeName == "google.protobuf.Struct" && field.parent.typeName != "google.protobuf.Value" && isObject(value)) {
|
|
1590
|
+
} else if (field.message.typeName == "google.protobuf.Struct" && field.parent.typeName != "google.protobuf.Value" && isObject$1(value)) {
|
|
1591
1591
|
value = wktStructToReflect(value);
|
|
1592
1592
|
}
|
|
1593
1593
|
}
|
|
@@ -1704,7 +1704,7 @@ function wktStructToReflect(json) {
|
|
|
1704
1704
|
$typeName: "google.protobuf.Struct",
|
|
1705
1705
|
fields: {}
|
|
1706
1706
|
};
|
|
1707
|
-
if (isObject(json)) {
|
|
1707
|
+
if (isObject$1(json)) {
|
|
1708
1708
|
for (const [k, v] of Object.entries(json)) {
|
|
1709
1709
|
struct.fields[k] = wktValueToReflect(v);
|
|
1710
1710
|
}
|
|
@@ -2172,15 +2172,15 @@ function createFileRegistry(...args) {
|
|
|
2172
2172
|
return registry;
|
|
2173
2173
|
}
|
|
2174
2174
|
function createBaseRegistry() {
|
|
2175
|
-
const
|
|
2175
|
+
const types = /* @__PURE__ */ new Map();
|
|
2176
2176
|
const extendees = /* @__PURE__ */ new Map();
|
|
2177
2177
|
const files = /* @__PURE__ */ new Map();
|
|
2178
2178
|
return {
|
|
2179
2179
|
kind: "registry",
|
|
2180
|
-
types
|
|
2180
|
+
types,
|
|
2181
2181
|
extendees,
|
|
2182
2182
|
[Symbol.iterator]() {
|
|
2183
|
-
return
|
|
2183
|
+
return types.values();
|
|
2184
2184
|
},
|
|
2185
2185
|
get files() {
|
|
2186
2186
|
return files.values();
|
|
@@ -2210,24 +2210,24 @@ function createBaseRegistry() {
|
|
|
2210
2210
|
}
|
|
2211
2211
|
numberToExt.set(desc.number, desc);
|
|
2212
2212
|
}
|
|
2213
|
-
|
|
2213
|
+
types.set(desc.typeName, desc);
|
|
2214
2214
|
},
|
|
2215
2215
|
get(typeName) {
|
|
2216
|
-
return
|
|
2216
|
+
return types.get(typeName);
|
|
2217
2217
|
},
|
|
2218
2218
|
getFile(fileName) {
|
|
2219
2219
|
return files.get(fileName);
|
|
2220
2220
|
},
|
|
2221
2221
|
getMessage(typeName) {
|
|
2222
|
-
const t =
|
|
2222
|
+
const t = types.get(typeName);
|
|
2223
2223
|
return (t === null || t === void 0 ? void 0 : t.kind) == "message" ? t : void 0;
|
|
2224
2224
|
},
|
|
2225
2225
|
getEnum(typeName) {
|
|
2226
|
-
const t =
|
|
2226
|
+
const t = types.get(typeName);
|
|
2227
2227
|
return (t === null || t === void 0 ? void 0 : t.kind) == "enum" ? t : void 0;
|
|
2228
2228
|
},
|
|
2229
2229
|
getExtension(typeName) {
|
|
2230
|
-
const t =
|
|
2230
|
+
const t = types.get(typeName);
|
|
2231
2231
|
return (t === null || t === void 0 ? void 0 : t.kind) == "extension" ? t : void 0;
|
|
2232
2232
|
},
|
|
2233
2233
|
getExtensionFor(extendee, no) {
|
|
@@ -2235,7 +2235,7 @@ function createBaseRegistry() {
|
|
|
2235
2235
|
return (_a = extendees.get(extendee.typeName)) === null || _a === void 0 ? void 0 : _a.get(no);
|
|
2236
2236
|
},
|
|
2237
2237
|
getService(typeName) {
|
|
2238
|
-
const t =
|
|
2238
|
+
const t = types.get(typeName);
|
|
2239
2239
|
return (t === null || t === void 0 ? void 0 : t.kind) == "service" ? t : void 0;
|
|
2240
2240
|
}
|
|
2241
2241
|
};
|
|
@@ -5238,7 +5238,7 @@ function createGrpcWebTransport(options) {
|
|
|
5238
5238
|
const useBinaryFormat = (_a = options.useBinaryFormat) !== null && _a !== void 0 ? _a : true;
|
|
5239
5239
|
return {
|
|
5240
5240
|
async unary(method, signal, timeoutMs, header, message, contextValues) {
|
|
5241
|
-
const { serialize, parse } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);
|
|
5241
|
+
const { serialize, parse: parse2 } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);
|
|
5242
5242
|
timeoutMs = timeoutMs === void 0 ? options.defaultTimeoutMs : timeoutMs <= 0 ? void 0 : timeoutMs;
|
|
5243
5243
|
return await runUnaryCall({
|
|
5244
5244
|
interceptors: options.interceptors,
|
|
@@ -5286,7 +5286,7 @@ function createGrpcWebTransport(options) {
|
|
|
5286
5286
|
if (message2 !== void 0) {
|
|
5287
5287
|
throw new ConnectError("extra message", Code$1.Unimplemented);
|
|
5288
5288
|
}
|
|
5289
|
-
message2 =
|
|
5289
|
+
message2 = parse2(data);
|
|
5290
5290
|
}
|
|
5291
5291
|
if (trailer === void 0) {
|
|
5292
5292
|
if (headerError !== void 0)
|
|
@@ -5309,7 +5309,7 @@ function createGrpcWebTransport(options) {
|
|
|
5309
5309
|
});
|
|
5310
5310
|
},
|
|
5311
5311
|
async stream(method, signal, timeoutMs, header, input, contextValues) {
|
|
5312
|
-
const { serialize, parse } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);
|
|
5312
|
+
const { serialize, parse: parse2 } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);
|
|
5313
5313
|
function parseResponseBody(body, foundStatus, trailerTarget, header2, signal2) {
|
|
5314
5314
|
return __asyncGenerator(this, arguments, function* parseResponseBody_1() {
|
|
5315
5315
|
const reader = createEnvelopeReadableStream(body).getReader();
|
|
@@ -5339,7 +5339,7 @@ function createGrpcWebTransport(options) {
|
|
|
5339
5339
|
if (trailerReceived) {
|
|
5340
5340
|
throw "extra message";
|
|
5341
5341
|
}
|
|
5342
|
-
yield yield __await(
|
|
5342
|
+
yield yield __await(parse2(data));
|
|
5343
5343
|
}
|
|
5344
5344
|
if ("throwIfAborted" in signal2) {
|
|
5345
5345
|
signal2.throwIfAborted();
|
|
@@ -6911,14 +6911,14 @@ function Long(low, high, unsigned) {
|
|
|
6911
6911
|
}
|
|
6912
6912
|
Long.prototype.__isLong__;
|
|
6913
6913
|
Object.defineProperty(Long.prototype, "__isLong__", { value: true });
|
|
6914
|
-
function isLong(obj) {
|
|
6914
|
+
function isLong$1(obj) {
|
|
6915
6915
|
return (obj && obj["__isLong__"]) === true;
|
|
6916
6916
|
}
|
|
6917
6917
|
function ctz32(value) {
|
|
6918
6918
|
var c = Math.clz32(value & -value);
|
|
6919
6919
|
return value ? 31 - c : c;
|
|
6920
6920
|
}
|
|
6921
|
-
Long.isLong = isLong;
|
|
6921
|
+
Long.isLong = isLong$1;
|
|
6922
6922
|
var INT_CACHE = {};
|
|
6923
6923
|
var UINT_CACHE = {};
|
|
6924
6924
|
function fromInt(value, unsigned) {
|
|
@@ -7104,7 +7104,7 @@ LongPrototype.isEven = function isEven() {
|
|
|
7104
7104
|
return (this.low & 1) === 0;
|
|
7105
7105
|
};
|
|
7106
7106
|
LongPrototype.equals = function equals(other) {
|
|
7107
|
-
if (!isLong(other)) other = fromValue(other);
|
|
7107
|
+
if (!isLong$1(other)) other = fromValue(other);
|
|
7108
7108
|
if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1)
|
|
7109
7109
|
return false;
|
|
7110
7110
|
return this.high === other.high && this.low === other.low;
|
|
@@ -7149,7 +7149,7 @@ LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
|
|
|
7149
7149
|
LongPrototype.gte = LongPrototype.greaterThanOrEqual;
|
|
7150
7150
|
LongPrototype.ge = LongPrototype.greaterThanOrEqual;
|
|
7151
7151
|
LongPrototype.compare = function compare(other) {
|
|
7152
|
-
if (!isLong(other)) other = fromValue(other);
|
|
7152
|
+
if (!isLong$1(other)) other = fromValue(other);
|
|
7153
7153
|
if (this.eq(other)) return 0;
|
|
7154
7154
|
var thisNeg = this.isNegative(), otherNeg = other.isNegative();
|
|
7155
7155
|
if (thisNeg && !otherNeg) return -1;
|
|
@@ -7164,7 +7164,7 @@ LongPrototype.negate = function negate2() {
|
|
|
7164
7164
|
};
|
|
7165
7165
|
LongPrototype.neg = LongPrototype.negate;
|
|
7166
7166
|
LongPrototype.add = function add(addend) {
|
|
7167
|
-
if (!isLong(addend)) addend = fromValue(addend);
|
|
7167
|
+
if (!isLong$1(addend)) addend = fromValue(addend);
|
|
7168
7168
|
var a48 = this.high >>> 16;
|
|
7169
7169
|
var a32 = this.high & 65535;
|
|
7170
7170
|
var a16 = this.low >>> 16;
|
|
@@ -7188,13 +7188,13 @@ LongPrototype.add = function add(addend) {
|
|
|
7188
7188
|
return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
|
|
7189
7189
|
};
|
|
7190
7190
|
LongPrototype.subtract = function subtract(subtrahend) {
|
|
7191
|
-
if (!isLong(subtrahend)) subtrahend = fromValue(subtrahend);
|
|
7191
|
+
if (!isLong$1(subtrahend)) subtrahend = fromValue(subtrahend);
|
|
7192
7192
|
return this.add(subtrahend.neg());
|
|
7193
7193
|
};
|
|
7194
7194
|
LongPrototype.sub = LongPrototype.subtract;
|
|
7195
7195
|
LongPrototype.multiply = function multiply(multiplier) {
|
|
7196
7196
|
if (this.isZero()) return this;
|
|
7197
|
-
if (!isLong(multiplier)) multiplier = fromValue(multiplier);
|
|
7197
|
+
if (!isLong$1(multiplier)) multiplier = fromValue(multiplier);
|
|
7198
7198
|
if (wasm) {
|
|
7199
7199
|
var low = wasm["mul"](this.low, this.high, multiplier.low, multiplier.high);
|
|
7200
7200
|
return fromBits(low, wasm["get_high"](), this.unsigned);
|
|
@@ -7241,7 +7241,7 @@ LongPrototype.multiply = function multiply(multiplier) {
|
|
|
7241
7241
|
};
|
|
7242
7242
|
LongPrototype.mul = LongPrototype.multiply;
|
|
7243
7243
|
LongPrototype.divide = function divide(divisor) {
|
|
7244
|
-
if (!isLong(divisor)) divisor = fromValue(divisor);
|
|
7244
|
+
if (!isLong$1(divisor)) divisor = fromValue(divisor);
|
|
7245
7245
|
if (divisor.isZero()) throw Error("division by zero");
|
|
7246
7246
|
if (wasm) {
|
|
7247
7247
|
if (!this.unsigned && this.high === -2147483648 && divisor.low === -1 && divisor.high === -1) {
|
|
@@ -7303,7 +7303,7 @@ LongPrototype.divide = function divide(divisor) {
|
|
|
7303
7303
|
};
|
|
7304
7304
|
LongPrototype.div = LongPrototype.divide;
|
|
7305
7305
|
LongPrototype.modulo = function modulo(divisor) {
|
|
7306
|
-
if (!isLong(divisor)) divisor = fromValue(divisor);
|
|
7306
|
+
if (!isLong$1(divisor)) divisor = fromValue(divisor);
|
|
7307
7307
|
if (wasm) {
|
|
7308
7308
|
var low = (this.unsigned ? wasm["rem_u"] : wasm["rem_s"])(
|
|
7309
7309
|
this.low,
|
|
@@ -7329,19 +7329,19 @@ LongPrototype.countTrailingZeros = function countTrailingZeros() {
|
|
|
7329
7329
|
};
|
|
7330
7330
|
LongPrototype.ctz = LongPrototype.countTrailingZeros;
|
|
7331
7331
|
LongPrototype.and = function and(other) {
|
|
7332
|
-
if (!isLong(other)) other = fromValue(other);
|
|
7332
|
+
if (!isLong$1(other)) other = fromValue(other);
|
|
7333
7333
|
return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
|
|
7334
7334
|
};
|
|
7335
7335
|
LongPrototype.or = function or(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.xor = function xor(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.shiftLeft = function shiftLeft(numBits) {
|
|
7344
|
-
if (isLong(numBits)) numBits = numBits.toInt();
|
|
7344
|
+
if (isLong$1(numBits)) numBits = numBits.toInt();
|
|
7345
7345
|
if ((numBits &= 63) === 0) return this;
|
|
7346
7346
|
else if (numBits < 32)
|
|
7347
7347
|
return fromBits(
|
|
@@ -7353,7 +7353,7 @@ LongPrototype.shiftLeft = function shiftLeft(numBits) {
|
|
|
7353
7353
|
};
|
|
7354
7354
|
LongPrototype.shl = LongPrototype.shiftLeft;
|
|
7355
7355
|
LongPrototype.shiftRight = function shiftRight(numBits) {
|
|
7356
|
-
if (isLong(numBits)) numBits = numBits.toInt();
|
|
7356
|
+
if (isLong$1(numBits)) numBits = numBits.toInt();
|
|
7357
7357
|
if ((numBits &= 63) === 0) return this;
|
|
7358
7358
|
else if (numBits < 32)
|
|
7359
7359
|
return fromBits(
|
|
@@ -7370,7 +7370,7 @@ LongPrototype.shiftRight = function shiftRight(numBits) {
|
|
|
7370
7370
|
};
|
|
7371
7371
|
LongPrototype.shr = LongPrototype.shiftRight;
|
|
7372
7372
|
LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
|
|
7373
|
-
if (isLong(numBits)) numBits = numBits.toInt();
|
|
7373
|
+
if (isLong$1(numBits)) numBits = numBits.toInt();
|
|
7374
7374
|
if ((numBits &= 63) === 0) return this;
|
|
7375
7375
|
if (numBits < 32)
|
|
7376
7376
|
return fromBits(
|
|
@@ -7385,7 +7385,7 @@ LongPrototype.shru = LongPrototype.shiftRightUnsigned;
|
|
|
7385
7385
|
LongPrototype.shr_u = LongPrototype.shiftRightUnsigned;
|
|
7386
7386
|
LongPrototype.rotateLeft = function rotateLeft(numBits) {
|
|
7387
7387
|
var b;
|
|
7388
|
-
if (isLong(numBits)) numBits = numBits.toInt();
|
|
7388
|
+
if (isLong$1(numBits)) numBits = numBits.toInt();
|
|
7389
7389
|
if ((numBits &= 63) === 0) return this;
|
|
7390
7390
|
if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
|
|
7391
7391
|
if (numBits < 32) {
|
|
@@ -7407,7 +7407,7 @@ LongPrototype.rotateLeft = function rotateLeft(numBits) {
|
|
|
7407
7407
|
LongPrototype.rotl = LongPrototype.rotateLeft;
|
|
7408
7408
|
LongPrototype.rotateRight = function rotateRight(numBits) {
|
|
7409
7409
|
var b;
|
|
7410
|
-
if (isLong(numBits)) numBits = numBits.toInt();
|
|
7410
|
+
if (isLong$1(numBits)) numBits = numBits.toInt();
|
|
7411
7411
|
if ((numBits &= 63) === 0) return this;
|
|
7412
7412
|
if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);
|
|
7413
7413
|
if (numBits < 32) {
|
|
@@ -17689,7 +17689,7 @@ function validatePrimitiveValue(value, rule) {
|
|
|
17689
17689
|
const EventSourceDevPanel = "yorkie-devtools-panel";
|
|
17690
17690
|
const EventSourceSDK = "yorkie-devtools-sdk";
|
|
17691
17691
|
function isDocEventForReplay(event) {
|
|
17692
|
-
const
|
|
17692
|
+
const types = [
|
|
17693
17693
|
DocEventType.StatusChanged,
|
|
17694
17694
|
DocEventType.Snapshot,
|
|
17695
17695
|
DocEventType.LocalChange,
|
|
@@ -17699,12 +17699,12 @@ function isDocEventForReplay(event) {
|
|
|
17699
17699
|
DocEventType.Unwatched,
|
|
17700
17700
|
DocEventType.PresenceChanged
|
|
17701
17701
|
];
|
|
17702
|
-
return
|
|
17702
|
+
return types.includes(event.type);
|
|
17703
17703
|
}
|
|
17704
17704
|
function isDocEventsForReplay(events) {
|
|
17705
17705
|
return events.every(isDocEventForReplay);
|
|
17706
17706
|
}
|
|
17707
|
-
const
|
|
17707
|
+
const Devtools = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
17708
17708
|
__proto__: null,
|
|
17709
17709
|
isDocEventForReplay,
|
|
17710
17710
|
isDocEventsForReplay
|
|
@@ -19014,7 +19014,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
19014
19014
|
};
|
|
19015
19015
|
}
|
|
19016
19016
|
const name = "@yorkie-js/sdk";
|
|
19017
|
-
const version = "0.6.41-
|
|
19017
|
+
const version = "0.6.41-rc3";
|
|
19018
19018
|
const pkg = {
|
|
19019
19019
|
name,
|
|
19020
19020
|
version
|
|
@@ -20594,6 +20594,201 @@ class Client {
|
|
|
20594
20594
|
this.processNext();
|
|
20595
20595
|
}
|
|
20596
20596
|
}
|
|
20597
|
+
function isText(value) {
|
|
20598
|
+
return typeof value === "object" && value !== null && value.type === "Text" && Array.isArray(value.nodes);
|
|
20599
|
+
}
|
|
20600
|
+
function isTree(value) {
|
|
20601
|
+
return typeof value === "object" && value !== null && value.type === "Tree" && typeof value.root === "object";
|
|
20602
|
+
}
|
|
20603
|
+
function isInt(value) {
|
|
20604
|
+
return typeof value === "object" && value !== null && value.type === "Int" && typeof value.value === "number";
|
|
20605
|
+
}
|
|
20606
|
+
function isLong(value) {
|
|
20607
|
+
return typeof value === "object" && value !== null && value.type === "Long" && typeof value.value === "number";
|
|
20608
|
+
}
|
|
20609
|
+
function isDate(value) {
|
|
20610
|
+
return typeof value === "object" && value !== null && value.type === "Date" && typeof value.value === "string";
|
|
20611
|
+
}
|
|
20612
|
+
function isBinData(value) {
|
|
20613
|
+
return typeof value === "object" && value !== null && value.type === "BinData" && typeof value.value === "string";
|
|
20614
|
+
}
|
|
20615
|
+
function isCounter(value) {
|
|
20616
|
+
return typeof value === "object" && value !== null && value.type === "Counter" && typeof value.value === "object";
|
|
20617
|
+
}
|
|
20618
|
+
function isObject(value) {
|
|
20619
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !isText(value) && !isTree(value) && !isInt(value) && !isLong(value) && !isDate(value) && !isBinData(value) && !isCounter(value);
|
|
20620
|
+
}
|
|
20621
|
+
function parse(yson) {
|
|
20622
|
+
try {
|
|
20623
|
+
const processed = preprocessYSON(yson);
|
|
20624
|
+
const parsed = JSON.parse(processed);
|
|
20625
|
+
return postprocessValue(parsed);
|
|
20626
|
+
} catch (err) {
|
|
20627
|
+
throw new YorkieError(
|
|
20628
|
+
Code.ErrInvalidArgument,
|
|
20629
|
+
`Failed to parse YSON: ${err instanceof Error ? err.message : String(err)}`
|
|
20630
|
+
);
|
|
20631
|
+
}
|
|
20632
|
+
}
|
|
20633
|
+
function preprocessYSON(yson) {
|
|
20634
|
+
let result = yson;
|
|
20635
|
+
result = result.replace(
|
|
20636
|
+
/Counter\((Int|Long)\((-?\d+)\)\)/g,
|
|
20637
|
+
(_, type, value) => {
|
|
20638
|
+
return `{"__yson_type":"Counter","__yson_data":{"__yson_type":"${type}","__yson_data":${value}}}`;
|
|
20639
|
+
}
|
|
20640
|
+
);
|
|
20641
|
+
result = result.replace(/Int\((-?\d+)\)/g, (_, value) => {
|
|
20642
|
+
return `{"__yson_type":"Int","__yson_data":${value}}`;
|
|
20643
|
+
});
|
|
20644
|
+
result = result.replace(/Long\((-?\d+)\)/g, (_, value) => {
|
|
20645
|
+
return `{"__yson_type":"Long","__yson_data":${value}}`;
|
|
20646
|
+
});
|
|
20647
|
+
result = result.replace(/Date\("([^"]*)"\)/g, (_, value) => {
|
|
20648
|
+
return `{"__yson_type":"Date","__yson_data":"${value}"}`;
|
|
20649
|
+
});
|
|
20650
|
+
result = result.replace(/BinData\("([^"]*)"\)/g, (_, value) => {
|
|
20651
|
+
return `{"__yson_type":"BinData","__yson_data":"${value}"}`;
|
|
20652
|
+
});
|
|
20653
|
+
result = result.replace(
|
|
20654
|
+
/Text\((\[(?:[^[\]]|\[(?:[^[\]]|\[[^[\]]*\])*\])*\])\)/g,
|
|
20655
|
+
(_, content) => {
|
|
20656
|
+
return `{"__yson_type":"Text","__yson_data":${content}}`;
|
|
20657
|
+
}
|
|
20658
|
+
);
|
|
20659
|
+
result = result.replace(
|
|
20660
|
+
/Tree\((\{[^{}]*(?:\{[^{}]*(?:\{[^{}]*\})*[^{}]*\})*[^{}]*\})\)/g,
|
|
20661
|
+
(_, content) => {
|
|
20662
|
+
return `{"__yson_type":"Tree","__yson_data":${content}}`;
|
|
20663
|
+
}
|
|
20664
|
+
);
|
|
20665
|
+
return result;
|
|
20666
|
+
}
|
|
20667
|
+
function postprocessValue(value) {
|
|
20668
|
+
if (value === null || typeof value !== "object") {
|
|
20669
|
+
return value;
|
|
20670
|
+
}
|
|
20671
|
+
if (value.__yson_type === "Int" && typeof value.__yson_data === "number") {
|
|
20672
|
+
return {
|
|
20673
|
+
type: "Int",
|
|
20674
|
+
value: value.__yson_data
|
|
20675
|
+
};
|
|
20676
|
+
}
|
|
20677
|
+
if (value.__yson_type === "Long" && typeof value.__yson_data === "number") {
|
|
20678
|
+
return {
|
|
20679
|
+
type: "Long",
|
|
20680
|
+
value: value.__yson_data
|
|
20681
|
+
};
|
|
20682
|
+
}
|
|
20683
|
+
if (value.__yson_type === "Date" && typeof value.__yson_data === "string") {
|
|
20684
|
+
return {
|
|
20685
|
+
type: "Date",
|
|
20686
|
+
value: value.__yson_data
|
|
20687
|
+
};
|
|
20688
|
+
}
|
|
20689
|
+
if (value.__yson_type === "BinData" && typeof value.__yson_data === "string") {
|
|
20690
|
+
return {
|
|
20691
|
+
type: "BinData",
|
|
20692
|
+
value: value.__yson_data
|
|
20693
|
+
};
|
|
20694
|
+
}
|
|
20695
|
+
if (value.__yson_type === "Counter" && typeof value.__yson_data === "object") {
|
|
20696
|
+
const counterValue = postprocessValue(value.__yson_data);
|
|
20697
|
+
if (typeof counterValue === "object" && counterValue !== null && "type" in counterValue && (counterValue.type === "Int" || counterValue.type === "Long")) {
|
|
20698
|
+
return {
|
|
20699
|
+
type: "Counter",
|
|
20700
|
+
value: counterValue
|
|
20701
|
+
};
|
|
20702
|
+
}
|
|
20703
|
+
throw new YorkieError(
|
|
20704
|
+
Code.ErrInvalidArgument,
|
|
20705
|
+
"Counter must contain Int or Long"
|
|
20706
|
+
);
|
|
20707
|
+
}
|
|
20708
|
+
if (value.__yson_type === "Text" && Array.isArray(value.__yson_data)) {
|
|
20709
|
+
return {
|
|
20710
|
+
type: "Text",
|
|
20711
|
+
nodes: value.__yson_data.map((node) => postprocessTextNode(node))
|
|
20712
|
+
};
|
|
20713
|
+
}
|
|
20714
|
+
if (value.__yson_type === "Tree" && typeof value.__yson_data === "object") {
|
|
20715
|
+
return {
|
|
20716
|
+
type: "Tree",
|
|
20717
|
+
root: postprocessTreeNode(value.__yson_data)
|
|
20718
|
+
};
|
|
20719
|
+
}
|
|
20720
|
+
if (Array.isArray(value)) {
|
|
20721
|
+
return value.map((item) => postprocessValue(item));
|
|
20722
|
+
}
|
|
20723
|
+
const result = {};
|
|
20724
|
+
for (const [key, val] of Object.entries(value)) {
|
|
20725
|
+
result[key] = postprocessValue(val);
|
|
20726
|
+
}
|
|
20727
|
+
return result;
|
|
20728
|
+
}
|
|
20729
|
+
function postprocessTextNode(node) {
|
|
20730
|
+
if (typeof node !== "object" || node === null || typeof node.val !== "string") {
|
|
20731
|
+
throw new YorkieError(Code.ErrInvalidArgument, "invalid text node format");
|
|
20732
|
+
}
|
|
20733
|
+
const result = { val: node.val };
|
|
20734
|
+
if (node.attrs && typeof node.attrs === "object") {
|
|
20735
|
+
result.attrs = node.attrs;
|
|
20736
|
+
}
|
|
20737
|
+
return result;
|
|
20738
|
+
}
|
|
20739
|
+
function postprocessTreeNode(node) {
|
|
20740
|
+
if (typeof node !== "object" || node === null || typeof node.type !== "string") {
|
|
20741
|
+
throw new YorkieError(Code.ErrInvalidArgument, "invalid tree node format");
|
|
20742
|
+
}
|
|
20743
|
+
const result = { type: node.type };
|
|
20744
|
+
if (node.type === "text" && typeof node.value === "string") {
|
|
20745
|
+
result.value = node.value;
|
|
20746
|
+
return result;
|
|
20747
|
+
}
|
|
20748
|
+
if (node.attrs && typeof node.attrs === "object") {
|
|
20749
|
+
result.attrs = node.attrs;
|
|
20750
|
+
}
|
|
20751
|
+
if (Array.isArray(node.children)) {
|
|
20752
|
+
result.children = node.children.map(
|
|
20753
|
+
(child) => postprocessTreeNode(child)
|
|
20754
|
+
);
|
|
20755
|
+
}
|
|
20756
|
+
return result;
|
|
20757
|
+
}
|
|
20758
|
+
function textToString(text) {
|
|
20759
|
+
return text.nodes.map((node) => node.val).join("");
|
|
20760
|
+
}
|
|
20761
|
+
function treeToXML(tree) {
|
|
20762
|
+
return treeNodeToXML(tree.root);
|
|
20763
|
+
}
|
|
20764
|
+
function treeNodeToXML(node) {
|
|
20765
|
+
const attrs = node.attrs ? Object.entries(node.attrs).map(([key, value]) => ` ${key}="${escapeXML(value)}"`).join("") : "";
|
|
20766
|
+
if (node.type === "text" && node.value !== void 0) {
|
|
20767
|
+
return `<${node.type}${attrs}>${escapeXML(node.value)}</${node.type}>`;
|
|
20768
|
+
}
|
|
20769
|
+
if (!node.children || node.children.length === 0) {
|
|
20770
|
+
return `<${node.type}${attrs} />`;
|
|
20771
|
+
}
|
|
20772
|
+
const children = node.children.map((child) => treeNodeToXML(child)).join("");
|
|
20773
|
+
return `<${node.type}${attrs}>${children}</${node.type}>`;
|
|
20774
|
+
}
|
|
20775
|
+
function escapeXML(str) {
|
|
20776
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
20777
|
+
}
|
|
20778
|
+
const YSON = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
20779
|
+
__proto__: null,
|
|
20780
|
+
isBinData,
|
|
20781
|
+
isCounter,
|
|
20782
|
+
isDate,
|
|
20783
|
+
isInt,
|
|
20784
|
+
isLong,
|
|
20785
|
+
isObject,
|
|
20786
|
+
isText,
|
|
20787
|
+
isTree,
|
|
20788
|
+
parse,
|
|
20789
|
+
textToString,
|
|
20790
|
+
treeToXML
|
|
20791
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
20597
20792
|
const yorkie = {
|
|
20598
20793
|
Client,
|
|
20599
20794
|
Document,
|
|
@@ -20601,8 +20796,10 @@ const yorkie = {
|
|
|
20601
20796
|
Text,
|
|
20602
20797
|
Counter,
|
|
20603
20798
|
Tree,
|
|
20799
|
+
Devtools,
|
|
20604
20800
|
Channel: Channel2,
|
|
20605
20801
|
ChannelEventType,
|
|
20802
|
+
YSON,
|
|
20606
20803
|
LogLevel,
|
|
20607
20804
|
setLogLevel,
|
|
20608
20805
|
IntType: CounterType.Int,
|
|
@@ -20618,6 +20815,7 @@ if (typeof globalThis !== "undefined") {
|
|
|
20618
20815
|
Tree,
|
|
20619
20816
|
Channel: Channel2,
|
|
20620
20817
|
ChannelEventType,
|
|
20818
|
+
YSON,
|
|
20621
20819
|
LogLevel,
|
|
20622
20820
|
setLogLevel,
|
|
20623
20821
|
IntType: CounterType.Int,
|
|
@@ -20634,7 +20832,7 @@ export {
|
|
|
20634
20832
|
ClientStatus,
|
|
20635
20833
|
Counter,
|
|
20636
20834
|
CounterType,
|
|
20637
|
-
|
|
20835
|
+
Devtools,
|
|
20638
20836
|
DocEventType,
|
|
20639
20837
|
DocStatus,
|
|
20640
20838
|
DocSyncStatus,
|
|
@@ -20651,6 +20849,7 @@ export {
|
|
|
20651
20849
|
TimeTicket,
|
|
20652
20850
|
Tree,
|
|
20653
20851
|
VersionVector,
|
|
20852
|
+
YSON,
|
|
20654
20853
|
converter,
|
|
20655
20854
|
yorkie as default,
|
|
20656
20855
|
setLogLevel
|