@valbuild/ui 0.32.0 → 0.33.0
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/valbuild-ui.cjs.d.ts +2 -4
- package/dist/valbuild-ui.cjs.js +26978 -26404
- package/dist/valbuild-ui.esm.js +26979 -26405
- package/package.json +3 -3
- package/server/.tmp/assets/index-a75a6d05.js +200 -0
- package/server/.tmp/index.html +1 -1
- package/server/dist/valbuild-ui-main.cjs.js +1257 -682
- package/server/dist/valbuild-ui-main.esm.js +1257 -682
- package/server/dist/valbuild-ui-server.cjs.js +1 -1
- package/server/dist/valbuild-ui-server.esm.js +1 -1
- package/server/.tmp/assets/index-9297054a.js +0 -197
|
@@ -31974,30 +31974,30 @@ if (process.env.NODE_ENV === "production") {
|
|
|
31974
31974
|
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
31975
31975
|
}
|
|
31976
31976
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
31977
|
-
function _arrayLikeToArray(arr, len) {
|
|
31977
|
+
function _arrayLikeToArray$1(arr, len) {
|
|
31978
31978
|
if (len == null || len > arr.length)
|
|
31979
31979
|
len = arr.length;
|
|
31980
31980
|
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
31981
31981
|
arr2[i] = arr[i];
|
|
31982
31982
|
return arr2;
|
|
31983
31983
|
}
|
|
31984
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
31984
|
+
function _unsupportedIterableToArray$1(o, minLen) {
|
|
31985
31985
|
if (!o)
|
|
31986
31986
|
return;
|
|
31987
31987
|
if (typeof o === "string")
|
|
31988
|
-
return _arrayLikeToArray(o, minLen);
|
|
31988
|
+
return _arrayLikeToArray$1(o, minLen);
|
|
31989
31989
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31990
31990
|
if (n === "Object" && o.constructor)
|
|
31991
31991
|
n = o.constructor.name;
|
|
31992
31992
|
if (n === "Map" || n === "Set")
|
|
31993
31993
|
return Array.from(o);
|
|
31994
31994
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
31995
|
-
return _arrayLikeToArray(o, minLen);
|
|
31995
|
+
return _arrayLikeToArray$1(o, minLen);
|
|
31996
31996
|
}
|
|
31997
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
31997
|
+
function _createForOfIteratorHelper$1(o, allowArrayLike) {
|
|
31998
31998
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
31999
31999
|
if (!it) {
|
|
32000
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
32000
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
32001
32001
|
if (it)
|
|
32002
32002
|
o = it;
|
|
32003
32003
|
var i = 0;
|
|
@@ -32078,7 +32078,7 @@ function isErr(result2) {
|
|
|
32078
32078
|
function allT(results) {
|
|
32079
32079
|
var values = [];
|
|
32080
32080
|
var errors = [];
|
|
32081
|
-
var _iterator = _createForOfIteratorHelper(results), _step;
|
|
32081
|
+
var _iterator = _createForOfIteratorHelper$1(results), _step;
|
|
32082
32082
|
try {
|
|
32083
32083
|
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
32084
32084
|
var _result = _step.value;
|
|
@@ -32104,7 +32104,7 @@ function all(results) {
|
|
|
32104
32104
|
}
|
|
32105
32105
|
function allV(results) {
|
|
32106
32106
|
var errs = [];
|
|
32107
|
-
var _iterator2 = _createForOfIteratorHelper(results), _step2;
|
|
32107
|
+
var _iterator2 = _createForOfIteratorHelper$1(results), _step2;
|
|
32108
32108
|
try {
|
|
32109
32109
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
|
|
32110
32110
|
var _result2 = _step2.value;
|
|
@@ -32197,7 +32197,7 @@ var result = /* @__PURE__ */ Object.freeze({
|
|
|
32197
32197
|
fromPredicate,
|
|
32198
32198
|
filterOrElse
|
|
32199
32199
|
});
|
|
32200
|
-
function _toPrimitive(input, hint) {
|
|
32200
|
+
function _toPrimitive$1(input, hint) {
|
|
32201
32201
|
if (typeof input !== "object" || input === null)
|
|
32202
32202
|
return input;
|
|
32203
32203
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -32209,12 +32209,12 @@ function _toPrimitive(input, hint) {
|
|
|
32209
32209
|
}
|
|
32210
32210
|
return (hint === "string" ? String : Number)(input);
|
|
32211
32211
|
}
|
|
32212
|
-
function _toPropertyKey(arg) {
|
|
32213
|
-
var key = _toPrimitive(arg, "string");
|
|
32212
|
+
function _toPropertyKey$1(arg) {
|
|
32213
|
+
var key = _toPrimitive$1(arg, "string");
|
|
32214
32214
|
return typeof key === "symbol" ? key : String(key);
|
|
32215
32215
|
}
|
|
32216
|
-
function _defineProperty(obj, key, value) {
|
|
32217
|
-
key = _toPropertyKey(key);
|
|
32216
|
+
function _defineProperty$1(obj, key, value) {
|
|
32217
|
+
key = _toPropertyKey$1(key);
|
|
32218
32218
|
if (key in obj) {
|
|
32219
32219
|
Object.defineProperty(obj, key, {
|
|
32220
32220
|
value,
|
|
@@ -32227,7 +32227,7 @@ function _defineProperty(obj, key, value) {
|
|
|
32227
32227
|
}
|
|
32228
32228
|
return obj;
|
|
32229
32229
|
}
|
|
32230
|
-
function ownKeys(e, r2) {
|
|
32230
|
+
function ownKeys$1(e, r2) {
|
|
32231
32231
|
var t = Object.keys(e);
|
|
32232
32232
|
if (Object.getOwnPropertySymbols) {
|
|
32233
32233
|
var o = Object.getOwnPropertySymbols(e);
|
|
@@ -32237,44 +32237,44 @@ function ownKeys(e, r2) {
|
|
|
32237
32237
|
}
|
|
32238
32238
|
return t;
|
|
32239
32239
|
}
|
|
32240
|
-
function _objectSpread2(e) {
|
|
32240
|
+
function _objectSpread2$1(e) {
|
|
32241
32241
|
for (var r2 = 1; r2 < arguments.length; r2++) {
|
|
32242
32242
|
var t = null != arguments[r2] ? arguments[r2] : {};
|
|
32243
|
-
r2 % 2 ? ownKeys(Object(t), true).forEach(function(r3) {
|
|
32244
|
-
_defineProperty(e, r3, t[r3]);
|
|
32245
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r3) {
|
|
32243
|
+
r2 % 2 ? ownKeys$1(Object(t), true).forEach(function(r3) {
|
|
32244
|
+
_defineProperty$1(e, r3, t[r3]);
|
|
32245
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r3) {
|
|
32246
32246
|
Object.defineProperty(e, r3, Object.getOwnPropertyDescriptor(t, r3));
|
|
32247
32247
|
});
|
|
32248
32248
|
}
|
|
32249
32249
|
return e;
|
|
32250
32250
|
}
|
|
32251
|
-
function _arrayWithoutHoles(arr) {
|
|
32251
|
+
function _arrayWithoutHoles$1(arr) {
|
|
32252
32252
|
if (Array.isArray(arr))
|
|
32253
|
-
return _arrayLikeToArray(arr);
|
|
32253
|
+
return _arrayLikeToArray$1(arr);
|
|
32254
32254
|
}
|
|
32255
|
-
function _iterableToArray(iter) {
|
|
32255
|
+
function _iterableToArray$1(iter) {
|
|
32256
32256
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
32257
32257
|
return Array.from(iter);
|
|
32258
32258
|
}
|
|
32259
|
-
function _nonIterableSpread() {
|
|
32259
|
+
function _nonIterableSpread$1() {
|
|
32260
32260
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
32261
32261
|
}
|
|
32262
|
-
function _toConsumableArray(arr) {
|
|
32263
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
32262
|
+
function _toConsumableArray$1(arr) {
|
|
32263
|
+
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
|
|
32264
32264
|
}
|
|
32265
|
-
function _typeof(o) {
|
|
32265
|
+
function _typeof$1(o) {
|
|
32266
32266
|
"@babel/helpers - typeof";
|
|
32267
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
32267
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
32268
32268
|
return typeof o2;
|
|
32269
32269
|
} : function(o2) {
|
|
32270
32270
|
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
32271
|
-
}, _typeof(o);
|
|
32271
|
+
}, _typeof$1(o);
|
|
32272
32272
|
}
|
|
32273
|
-
function _arrayWithHoles(arr) {
|
|
32273
|
+
function _arrayWithHoles$1(arr) {
|
|
32274
32274
|
if (Array.isArray(arr))
|
|
32275
32275
|
return arr;
|
|
32276
32276
|
}
|
|
32277
|
-
function _iterableToArrayLimit(r2, l) {
|
|
32277
|
+
function _iterableToArrayLimit$1(r2, l) {
|
|
32278
32278
|
var t = null == r2 ? null : "undefined" != typeof Symbol && r2[Symbol.iterator] || r2["@@iterator"];
|
|
32279
32279
|
if (null != t) {
|
|
32280
32280
|
var e, n, i, u, a = [], f = true, o = false;
|
|
@@ -32300,11 +32300,11 @@ function _iterableToArrayLimit(r2, l) {
|
|
|
32300
32300
|
return a;
|
|
32301
32301
|
}
|
|
32302
32302
|
}
|
|
32303
|
-
function _nonIterableRest() {
|
|
32303
|
+
function _nonIterableRest$1() {
|
|
32304
32304
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
32305
32305
|
}
|
|
32306
|
-
function _slicedToArray(arr, i) {
|
|
32307
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
32306
|
+
function _slicedToArray$1(arr, i) {
|
|
32307
|
+
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
|
|
32308
32308
|
}
|
|
32309
32309
|
function _classCallCheck(instance, Constructor) {
|
|
32310
32310
|
if (!(instance instanceof Constructor)) {
|
|
@@ -32318,7 +32318,7 @@ function _defineProperties(target, props) {
|
|
|
32318
32318
|
descriptor.configurable = true;
|
|
32319
32319
|
if ("value" in descriptor)
|
|
32320
32320
|
descriptor.writable = true;
|
|
32321
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
32321
|
+
Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);
|
|
32322
32322
|
}
|
|
32323
32323
|
}
|
|
32324
32324
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
@@ -32432,7 +32432,7 @@ var Schema = /* @__PURE__ */ function() {
|
|
|
32432
32432
|
}
|
|
32433
32433
|
return current;
|
|
32434
32434
|
} else {
|
|
32435
|
-
return _defineProperty({}, path, [{
|
|
32435
|
+
return _defineProperty$1({}, path, [{
|
|
32436
32436
|
message,
|
|
32437
32437
|
value
|
|
32438
32438
|
}]);
|
|
@@ -32459,7 +32459,7 @@ var Sym = /* @__PURE__ */ function(_Expr2) {
|
|
|
32459
32459
|
var _this2;
|
|
32460
32460
|
_classCallCheck(this, Sym2);
|
|
32461
32461
|
_this2 = _super2.call(this, span);
|
|
32462
|
-
_defineProperty(_assertThisInitialized(_this2), "type", "Sym");
|
|
32462
|
+
_defineProperty$1(_assertThisInitialized(_this2), "type", "Sym");
|
|
32463
32463
|
_this2.value = value;
|
|
32464
32464
|
return _this2;
|
|
32465
32465
|
}
|
|
@@ -32493,32 +32493,32 @@ var ImageSchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32493
32493
|
return false;
|
|
32494
32494
|
}
|
|
32495
32495
|
if (src === null || src === void 0) {
|
|
32496
|
-
return _defineProperty({}, path, [{
|
|
32496
|
+
return _defineProperty$1({}, path, [{
|
|
32497
32497
|
message: "Non-optional image was null or undefined.",
|
|
32498
32498
|
value: src
|
|
32499
32499
|
}]);
|
|
32500
32500
|
}
|
|
32501
32501
|
if (typeof src[FILE_REF_PROP] !== "string") {
|
|
32502
|
-
return _defineProperty({}, path, [{
|
|
32503
|
-
message: "Image did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
|
|
32502
|
+
return _defineProperty$1({}, path, [{
|
|
32503
|
+
message: "Image did not have a file reference string. Got: ".concat(_typeof$1(src[FILE_REF_PROP])),
|
|
32504
32504
|
value: src
|
|
32505
32505
|
}]);
|
|
32506
32506
|
}
|
|
32507
32507
|
if (src[VAL_EXTENSION] !== "file") {
|
|
32508
|
-
return _defineProperty({}, path, [{
|
|
32508
|
+
return _defineProperty$1({}, path, [{
|
|
32509
32509
|
message: "Image did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
|
32510
32510
|
value: src
|
|
32511
32511
|
}]);
|
|
32512
32512
|
}
|
|
32513
32513
|
if (src.metadata) {
|
|
32514
|
-
return _defineProperty({}, path, [{
|
|
32514
|
+
return _defineProperty$1({}, path, [{
|
|
32515
32515
|
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
|
|
32516
32516
|
// These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
|
|
32517
32517
|
value: src,
|
|
32518
32518
|
fixes: ["image:replace-metadata"]
|
|
32519
32519
|
}]);
|
|
32520
32520
|
}
|
|
32521
|
-
return _defineProperty({}, path, [{
|
|
32521
|
+
return _defineProperty$1({}, path, [{
|
|
32522
32522
|
message: "Could not validate Image metadata.",
|
|
32523
32523
|
value: src,
|
|
32524
32524
|
fixes: ["image:add-metadata"]
|
|
@@ -32564,10 +32564,10 @@ var convertFileSource = function convertFileSource2(src) {
|
|
|
32564
32564
|
};
|
|
32565
32565
|
};
|
|
32566
32566
|
function isSerializedVal(val) {
|
|
32567
|
-
return _typeof(val) === "object" && val !== null && val !== void 0 && ("val" in val || "valPath" in val);
|
|
32567
|
+
return _typeof$1(val) === "object" && val !== null && val !== void 0 && ("val" in val || "valPath" in val);
|
|
32568
32568
|
}
|
|
32569
32569
|
function isVal(val) {
|
|
32570
|
-
return _typeof(val) === "object" && val !== null && val !== void 0 && Path in val && "val" in val;
|
|
32570
|
+
return _typeof$1(val) === "object" && val !== null && val !== void 0 && Path in val && "val" in val;
|
|
32571
32571
|
}
|
|
32572
32572
|
function getValPath(valOrSelector) {
|
|
32573
32573
|
return valOrSelector[Path];
|
|
@@ -32582,11 +32582,11 @@ function _andThen(f, source, path) {
|
|
|
32582
32582
|
return newSelectorProxy(source, path);
|
|
32583
32583
|
}
|
|
32584
32584
|
function isSelector(source) {
|
|
32585
|
-
return _typeof(source) === "object" && source !== null && (GetSource in source || Path in source);
|
|
32585
|
+
return _typeof$1(source) === "object" && source !== null && (GetSource in source || Path in source);
|
|
32586
32586
|
}
|
|
32587
32587
|
function newSelectorProxy(source, path, moduleSchema) {
|
|
32588
32588
|
var _ref;
|
|
32589
|
-
if (_typeof(source) === "object") {
|
|
32589
|
+
if (_typeof$1(source) === "object") {
|
|
32590
32590
|
if (isSelector(source)) {
|
|
32591
32591
|
return source;
|
|
32592
32592
|
} else if (isSerializedVal(source)) {
|
|
@@ -32600,10 +32600,10 @@ function newSelectorProxy(source, path, moduleSchema) {
|
|
|
32600
32600
|
}
|
|
32601
32601
|
return newSelectorProxy(convertFileSource(source), path, moduleSchema);
|
|
32602
32602
|
}
|
|
32603
|
-
switch (_typeof(source)) {
|
|
32603
|
+
switch (_typeof$1(source)) {
|
|
32604
32604
|
case "function":
|
|
32605
32605
|
case "symbol":
|
|
32606
|
-
throw Error("Invalid selector type: ".concat(_typeof(source), ": ").concat(source));
|
|
32606
|
+
throw Error("Invalid selector type: ".concat(_typeof$1(source), ": ").concat(source));
|
|
32607
32607
|
case "object":
|
|
32608
32608
|
if (source !== null) {
|
|
32609
32609
|
return new Proxy(source, {
|
|
@@ -32694,17 +32694,17 @@ function newSelectorProxy(source, path, moduleSchema) {
|
|
|
32694
32694
|
andThen: function andThen(f) {
|
|
32695
32695
|
return _andThen(f, source === void 0 ? null : source, path);
|
|
32696
32696
|
}
|
|
32697
|
-
}, _defineProperty(_ref, GetSource, source === void 0 ? null : source), _defineProperty(_ref, Path, path), _defineProperty(_ref, GetSchema, moduleSchema), _ref;
|
|
32697
|
+
}, _defineProperty$1(_ref, GetSource, source === void 0 ? null : source), _defineProperty$1(_ref, Path, path), _defineProperty$1(_ref, GetSchema, moduleSchema), _ref;
|
|
32698
32698
|
}
|
|
32699
32699
|
}
|
|
32700
32700
|
function createValPathOfItem$1(arrayPath, prop) {
|
|
32701
|
-
if (_typeof(prop) === "symbol") {
|
|
32701
|
+
if (_typeof$1(prop) === "symbol") {
|
|
32702
32702
|
throw Error("Cannot create val path of array item with symbol prop: ".concat(prop.toString()));
|
|
32703
32703
|
}
|
|
32704
32704
|
return arrayPath && "".concat(arrayPath, ".").concat(JSON.stringify(prop));
|
|
32705
32705
|
}
|
|
32706
32706
|
function unValify(valueOrSelector) {
|
|
32707
|
-
if (_typeof(valueOrSelector) === "object" && (GetSource in valueOrSelector || Path in valueOrSelector)) {
|
|
32707
|
+
if (_typeof$1(valueOrSelector) === "object" && (GetSource in valueOrSelector || Path in valueOrSelector)) {
|
|
32708
32708
|
var selectorValue = valueOrSelector[GetSource];
|
|
32709
32709
|
return selectorValue;
|
|
32710
32710
|
}
|
|
@@ -32730,17 +32730,17 @@ var ObjectSchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32730
32730
|
if (this.opt && (src === null || src === void 0)) {
|
|
32731
32731
|
return false;
|
|
32732
32732
|
}
|
|
32733
|
-
if (_typeof(src) !== "object") {
|
|
32734
|
-
return _defineProperty({}, path, [{
|
|
32735
|
-
message: "Expected 'object', got '".concat(_typeof(src), "'")
|
|
32733
|
+
if (_typeof$1(src) !== "object") {
|
|
32734
|
+
return _defineProperty$1({}, path, [{
|
|
32735
|
+
message: "Expected 'object', got '".concat(_typeof$1(src), "'")
|
|
32736
32736
|
}]);
|
|
32737
32737
|
} else if (Array.isArray(src)) {
|
|
32738
|
-
return _defineProperty({}, path, [{
|
|
32738
|
+
return _defineProperty$1({}, path, [{
|
|
32739
32739
|
message: "Expected 'object', got 'array'"
|
|
32740
32740
|
}]);
|
|
32741
32741
|
}
|
|
32742
32742
|
Object.entries(this.items).forEach(function(_ref3) {
|
|
32743
|
-
var _ref4 = _slicedToArray(_ref3, 2), key = _ref4[0], schema = _ref4[1];
|
|
32743
|
+
var _ref4 = _slicedToArray$1(_ref3, 2), key = _ref4[0], schema = _ref4[1];
|
|
32744
32744
|
var subPath = createValPathOfItem$1(path, key);
|
|
32745
32745
|
if (!subPath) {
|
|
32746
32746
|
error = _this2.appendValidationError(
|
|
@@ -32753,7 +32753,7 @@ var ObjectSchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32753
32753
|
} else {
|
|
32754
32754
|
var subError = schema.validate(subPath, src[key]);
|
|
32755
32755
|
if (subError && error) {
|
|
32756
|
-
error = _objectSpread2(_objectSpread2({}, subError), error);
|
|
32756
|
+
error = _objectSpread2$1(_objectSpread2$1({}, subError), error);
|
|
32757
32757
|
} else if (subError) {
|
|
32758
32758
|
error = subError;
|
|
32759
32759
|
}
|
|
@@ -32771,12 +32771,12 @@ var ObjectSchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32771
32771
|
return false;
|
|
32772
32772
|
}
|
|
32773
32773
|
for (var _i = 0, _Object$entries = Object.entries(this.items); _i < _Object$entries.length; _i++) {
|
|
32774
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), _key = _Object$entries$_i[0], schema = _Object$entries$_i[1];
|
|
32774
|
+
var _Object$entries$_i = _slicedToArray$1(_Object$entries[_i], 2), _key = _Object$entries$_i[0], schema = _Object$entries$_i[1];
|
|
32775
32775
|
if (!schema.assert(src[_key])) {
|
|
32776
32776
|
return false;
|
|
32777
32777
|
}
|
|
32778
32778
|
}
|
|
32779
|
-
return _typeof(src) === "object" && !Array.isArray(src);
|
|
32779
|
+
return _typeof$1(src) === "object" && !Array.isArray(src);
|
|
32780
32780
|
}
|
|
32781
32781
|
}, {
|
|
32782
32782
|
key: "optional",
|
|
@@ -32789,7 +32789,7 @@ var ObjectSchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32789
32789
|
return {
|
|
32790
32790
|
type: "object",
|
|
32791
32791
|
items: Object.fromEntries(Object.entries(this.items).map(function(_ref5) {
|
|
32792
|
-
var _ref6 = _slicedToArray(_ref5, 2), key = _ref6[0], schema = _ref6[1];
|
|
32792
|
+
var _ref6 = _slicedToArray$1(_ref5, 2), key = _ref6[0], schema = _ref6[1];
|
|
32793
32793
|
return [key, schema.serialize()];
|
|
32794
32794
|
})),
|
|
32795
32795
|
opt: this.opt
|
|
@@ -32818,9 +32818,9 @@ var ArraySchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32818
32818
|
if (this.opt && (src === null || src === void 0)) {
|
|
32819
32819
|
return false;
|
|
32820
32820
|
}
|
|
32821
|
-
if (_typeof(src) !== "object" || !Array.isArray(src)) {
|
|
32822
|
-
return _defineProperty({}, path, [{
|
|
32823
|
-
message: "Expected 'array', got '".concat(_typeof(src), "'")
|
|
32821
|
+
if (_typeof$1(src) !== "object" || !Array.isArray(src)) {
|
|
32822
|
+
return _defineProperty$1({}, path, [{
|
|
32823
|
+
message: "Expected 'array', got '".concat(_typeof$1(src), "'")
|
|
32824
32824
|
}]);
|
|
32825
32825
|
}
|
|
32826
32826
|
src.forEach(function(i, idx) {
|
|
@@ -32836,7 +32836,7 @@ var ArraySchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32836
32836
|
} else {
|
|
32837
32837
|
var subError = _this2.item.validate(subPath, i);
|
|
32838
32838
|
if (subError && error) {
|
|
32839
|
-
error = _objectSpread2(_objectSpread2({}, subError), error);
|
|
32839
|
+
error = _objectSpread2$1(_objectSpread2$1({}, subError), error);
|
|
32840
32840
|
} else if (subError) {
|
|
32841
32841
|
error = subError;
|
|
32842
32842
|
}
|
|
@@ -32853,7 +32853,7 @@ var ArraySchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32853
32853
|
if (!src) {
|
|
32854
32854
|
return false;
|
|
32855
32855
|
}
|
|
32856
|
-
var _iterator = _createForOfIteratorHelper(src), _step;
|
|
32856
|
+
var _iterator = _createForOfIteratorHelper$1(src), _step;
|
|
32857
32857
|
try {
|
|
32858
32858
|
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
32859
32859
|
var _item = _step.value;
|
|
@@ -32866,7 +32866,7 @@ var ArraySchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32866
32866
|
} finally {
|
|
32867
32867
|
_iterator.f();
|
|
32868
32868
|
}
|
|
32869
|
-
return _typeof(src) === "object" && Array.isArray(src);
|
|
32869
|
+
return _typeof$1(src) === "object" && Array.isArray(src);
|
|
32870
32870
|
}
|
|
32871
32871
|
}, {
|
|
32872
32872
|
key: "optional",
|
|
@@ -32986,18 +32986,18 @@ var RecordSchema = /* @__PURE__ */ function(_Schema) {
|
|
|
32986
32986
|
if (this.opt && (src === null || src === void 0)) {
|
|
32987
32987
|
return false;
|
|
32988
32988
|
}
|
|
32989
|
-
if (_typeof(src) !== "object") {
|
|
32990
|
-
return _defineProperty({}, path, [{
|
|
32991
|
-
message: "Expected 'object', got '".concat(_typeof(src), "'")
|
|
32989
|
+
if (_typeof$1(src) !== "object") {
|
|
32990
|
+
return _defineProperty$1({}, path, [{
|
|
32991
|
+
message: "Expected 'object', got '".concat(_typeof$1(src), "'")
|
|
32992
32992
|
}]);
|
|
32993
32993
|
}
|
|
32994
32994
|
if (Array.isArray(src)) {
|
|
32995
|
-
return _defineProperty({}, path, [{
|
|
32995
|
+
return _defineProperty$1({}, path, [{
|
|
32996
32996
|
message: "Expected 'object', got 'array'"
|
|
32997
32997
|
}]);
|
|
32998
32998
|
}
|
|
32999
32999
|
Object.entries(src).forEach(function(_ref3) {
|
|
33000
|
-
var _ref4 = _slicedToArray(_ref3, 2), key = _ref4[0], elem = _ref4[1];
|
|
33000
|
+
var _ref4 = _slicedToArray$1(_ref3, 2), key = _ref4[0], elem = _ref4[1];
|
|
33001
33001
|
var subPath = createValPathOfItem$1(path, key);
|
|
33002
33002
|
if (!subPath) {
|
|
33003
33003
|
error = _this2.appendValidationError(
|
|
@@ -33010,7 +33010,7 @@ var RecordSchema = /* @__PURE__ */ function(_Schema) {
|
|
|
33010
33010
|
} else {
|
|
33011
33011
|
var subError = _this2.item.validate(subPath, elem);
|
|
33012
33012
|
if (subError && error) {
|
|
33013
|
-
error = _objectSpread2(_objectSpread2({}, subError), error);
|
|
33013
|
+
error = _objectSpread2$1(_objectSpread2$1({}, subError), error);
|
|
33014
33014
|
} else if (subError) {
|
|
33015
33015
|
error = subError;
|
|
33016
33016
|
}
|
|
@@ -33028,12 +33028,12 @@ var RecordSchema = /* @__PURE__ */ function(_Schema) {
|
|
|
33028
33028
|
return false;
|
|
33029
33029
|
}
|
|
33030
33030
|
for (var _i = 0, _Object$entries = Object.entries(src); _i < _Object$entries.length; _i++) {
|
|
33031
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), _item = _Object$entries$_i[1];
|
|
33031
|
+
var _Object$entries$_i = _slicedToArray$1(_Object$entries[_i], 2), _item = _Object$entries$_i[1];
|
|
33032
33032
|
if (!this.item.assert(_item)) {
|
|
33033
33033
|
return false;
|
|
33034
33034
|
}
|
|
33035
33035
|
}
|
|
33036
|
-
return _typeof(src) === "object" && !Array.isArray(src);
|
|
33036
|
+
return _typeof$1(src) === "object" && !Array.isArray(src);
|
|
33037
33037
|
}
|
|
33038
33038
|
}, {
|
|
33039
33039
|
key: "optional",
|
|
@@ -33067,26 +33067,26 @@ function splitModuleIdAndModulePath(path) {
|
|
|
33067
33067
|
return [path.slice(0, path.indexOf(".")), path.slice(path.indexOf(".") + 1)];
|
|
33068
33068
|
}
|
|
33069
33069
|
function isObjectSchema(schema) {
|
|
33070
|
-
return schema instanceof ObjectSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "object";
|
|
33070
|
+
return schema instanceof ObjectSchema || _typeof$1(schema) === "object" && "type" in schema && schema.type === "object";
|
|
33071
33071
|
}
|
|
33072
33072
|
function isRecordSchema(schema) {
|
|
33073
|
-
return schema instanceof RecordSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "record";
|
|
33073
|
+
return schema instanceof RecordSchema || _typeof$1(schema) === "object" && "type" in schema && schema.type === "record";
|
|
33074
33074
|
}
|
|
33075
33075
|
function isArraySchema(schema) {
|
|
33076
|
-
return schema instanceof ArraySchema || _typeof(schema) === "object" && "type" in schema && schema.type === "array";
|
|
33076
|
+
return schema instanceof ArraySchema || _typeof$1(schema) === "object" && "type" in schema && schema.type === "array";
|
|
33077
33077
|
}
|
|
33078
33078
|
function isUnionSchema(schema) {
|
|
33079
|
-
return schema instanceof UnionSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "union";
|
|
33079
|
+
return schema instanceof UnionSchema || _typeof$1(schema) === "object" && "type" in schema && schema.type === "union";
|
|
33080
33080
|
}
|
|
33081
33081
|
function isRichTextSchema(schema) {
|
|
33082
|
-
return schema instanceof RichTextSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "richtext";
|
|
33082
|
+
return schema instanceof RichTextSchema || _typeof$1(schema) === "object" && "type" in schema && schema.type === "richtext";
|
|
33083
33083
|
}
|
|
33084
33084
|
function isImageSchema(schema) {
|
|
33085
|
-
return schema instanceof ImageSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "image";
|
|
33085
|
+
return schema instanceof ImageSchema || _typeof$1(schema) === "object" && "type" in schema && schema.type === "image";
|
|
33086
33086
|
}
|
|
33087
33087
|
function resolvePath$1(path, valModule, schema) {
|
|
33088
33088
|
var parts = parsePath$1(path);
|
|
33089
|
-
var origParts = _toConsumableArray(parts);
|
|
33089
|
+
var origParts = _toConsumableArray$1(parts);
|
|
33090
33090
|
var resolvedSchema = schema;
|
|
33091
33091
|
var resolvedSource = valModule;
|
|
33092
33092
|
var _loop = function _loop2() {
|
|
@@ -33098,8 +33098,8 @@ function resolvePath$1(path, valModule, schema) {
|
|
|
33098
33098
|
if (Number.isNaN(Number(part))) {
|
|
33099
33099
|
throw Error("Invalid path: array schema ".concat(JSON.stringify(resolvedSchema), " must have a number as path, but got ").concat(part, ". Path: ").concat(path));
|
|
33100
33100
|
}
|
|
33101
|
-
if (_typeof(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
|
|
33102
|
-
throw Error("Schema type error: expected source to be type of array, but got ".concat(_typeof(resolvedSource)));
|
|
33101
|
+
if (_typeof$1(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
|
|
33102
|
+
throw Error("Schema type error: expected source to be type of array, but got ".concat(_typeof$1(resolvedSource)));
|
|
33103
33103
|
}
|
|
33104
33104
|
if (!resolvedSource[part]) {
|
|
33105
33105
|
var _resolvedSource;
|
|
@@ -33111,8 +33111,8 @@ function resolvePath$1(path, valModule, schema) {
|
|
|
33111
33111
|
if (typeof part !== "string") {
|
|
33112
33112
|
throw Error("Invalid path: record schema ".concat(resolvedSchema, " must have path: ").concat(part, " as string"));
|
|
33113
33113
|
}
|
|
33114
|
-
if (_typeof(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
|
|
33115
|
-
throw Error("Schema type error: expected source to be type of record, but got ".concat(_typeof(resolvedSource)));
|
|
33114
|
+
if (_typeof$1(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
|
|
33115
|
+
throw Error("Schema type error: expected source to be type of record, but got ".concat(_typeof$1(resolvedSource)));
|
|
33116
33116
|
}
|
|
33117
33117
|
if (!resolvedSource[part]) {
|
|
33118
33118
|
throw Error("Invalid path: record source did not have key ".concat(part, " from path: ").concat(path));
|
|
@@ -33120,8 +33120,8 @@ function resolvePath$1(path, valModule, schema) {
|
|
|
33120
33120
|
resolvedSource = resolvedSource[part];
|
|
33121
33121
|
resolvedSchema = resolvedSchema.item;
|
|
33122
33122
|
} else if (isObjectSchema(resolvedSchema)) {
|
|
33123
|
-
if (_typeof(resolvedSource) !== "object") {
|
|
33124
|
-
throw Error("Schema type error: expected source to be type of object, but got ".concat(_typeof(resolvedSource)));
|
|
33123
|
+
if (_typeof$1(resolvedSource) !== "object") {
|
|
33124
|
+
throw Error("Schema type error: expected source to be type of object, but got ".concat(_typeof$1(resolvedSource)));
|
|
33125
33125
|
}
|
|
33126
33126
|
if (!resolvedSource[part]) {
|
|
33127
33127
|
throw Error("Invalid path: object source did not have key ".concat(part, " from path: ").concat(path));
|
|
@@ -33174,7 +33174,7 @@ function resolvePath$1(path, valModule, schema) {
|
|
|
33174
33174
|
};
|
|
33175
33175
|
while (parts.length > 0) {
|
|
33176
33176
|
var _ret = _loop();
|
|
33177
|
-
if (_typeof(_ret) === "object")
|
|
33177
|
+
if (_typeof$1(_ret) === "object")
|
|
33178
33178
|
return _ret.v;
|
|
33179
33179
|
}
|
|
33180
33180
|
if (parts.length > 0) {
|
|
@@ -33231,15 +33231,15 @@ function getVal(selector) {
|
|
|
33231
33231
|
}
|
|
33232
33232
|
function isArrayOrArraySelector(child) {
|
|
33233
33233
|
if (isSelector(child)) {
|
|
33234
|
-
return _typeof(child[GetSource]) === "object" && _typeof(child[GetSource]) !== null && Array.isArray(child[GetSource]);
|
|
33234
|
+
return _typeof$1(child[GetSource]) === "object" && _typeof$1(child[GetSource]) !== null && Array.isArray(child[GetSource]);
|
|
33235
33235
|
}
|
|
33236
33236
|
return Array.isArray(child);
|
|
33237
33237
|
}
|
|
33238
33238
|
function isObjectOrObjectSelector(child) {
|
|
33239
33239
|
if (isSelector(child)) {
|
|
33240
|
-
return _typeof(child[GetSource]) === "object" && _typeof(child[GetSource]) !== null && !Array.isArray(child[GetSource]);
|
|
33240
|
+
return _typeof$1(child[GetSource]) === "object" && _typeof$1(child[GetSource]) !== null && !Array.isArray(child[GetSource]);
|
|
33241
33241
|
}
|
|
33242
|
-
return _typeof(child) === "object";
|
|
33242
|
+
return _typeof$1(child) === "object";
|
|
33243
33243
|
}
|
|
33244
33244
|
function serializedValOfSelectorSource(selector) {
|
|
33245
33245
|
var wrappedSelector = newSelectorProxy(selector);
|
|
@@ -33260,7 +33260,7 @@ function serializedValOfSelectorSource(selector) {
|
|
|
33260
33260
|
var _valPath = Path in child ? child[Path] : void 0;
|
|
33261
33261
|
return {
|
|
33262
33262
|
val: obj !== null && Object.fromEntries(Object.entries(obj).map(function(_ref) {
|
|
33263
|
-
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
33263
|
+
var _ref2 = _slicedToArray$1(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
33264
33264
|
return [key, rec(isSelector(value) ? value : newSelectorProxy(value, createValPathOfItem$1(_valPath, key)))];
|
|
33265
33265
|
})),
|
|
33266
33266
|
valPath: _valPath
|
|
@@ -33278,10 +33278,10 @@ function serializedValOfSelectorSource(selector) {
|
|
|
33278
33278
|
}
|
|
33279
33279
|
function strip(value) {
|
|
33280
33280
|
var val = isSerializedVal(value) ? value.val : value;
|
|
33281
|
-
switch (_typeof(val)) {
|
|
33281
|
+
switch (_typeof$1(val)) {
|
|
33282
33282
|
case "function":
|
|
33283
33283
|
case "symbol":
|
|
33284
|
-
throw Error("Invalid val type: ".concat(_typeof(val)));
|
|
33284
|
+
throw Error("Invalid val type: ".concat(_typeof$1(val)));
|
|
33285
33285
|
case "object":
|
|
33286
33286
|
if (val === null) {
|
|
33287
33287
|
return null;
|
|
@@ -33289,7 +33289,7 @@ function strip(value) {
|
|
|
33289
33289
|
return val.map(strip);
|
|
33290
33290
|
} else {
|
|
33291
33291
|
return Object.fromEntries(Object.entries(val).map(function(_ref3) {
|
|
33292
|
-
var _ref4 = _slicedToArray(_ref3, 2), key = _ref4[0], value2 = _ref4[1];
|
|
33292
|
+
var _ref4 = _slicedToArray$1(_ref3, 2), key = _ref4[0], value2 = _ref4[1];
|
|
33293
33293
|
return [key, value2 && strip(value2)];
|
|
33294
33294
|
}));
|
|
33295
33295
|
}
|
|
@@ -33300,10 +33300,10 @@ function strip(value) {
|
|
|
33300
33300
|
function newValProxy(val) {
|
|
33301
33301
|
var _ref5;
|
|
33302
33302
|
var source = val.val;
|
|
33303
|
-
switch (_typeof(source)) {
|
|
33303
|
+
switch (_typeof$1(source)) {
|
|
33304
33304
|
case "function":
|
|
33305
33305
|
case "symbol":
|
|
33306
|
-
throw Error("Invalid val type: ".concat(_typeof(source)));
|
|
33306
|
+
throw Error("Invalid val type: ".concat(_typeof$1(source)));
|
|
33307
33307
|
case "object":
|
|
33308
33308
|
if (source !== null) {
|
|
33309
33309
|
return new Proxy(source, {
|
|
@@ -33338,14 +33338,14 @@ function newValProxy(val) {
|
|
|
33338
33338
|
});
|
|
33339
33339
|
}
|
|
33340
33340
|
default:
|
|
33341
|
-
return _ref5 = {}, _defineProperty(_ref5, Path, val.valPath), _defineProperty(_ref5, "val", val.val), _ref5;
|
|
33341
|
+
return _ref5 = {}, _defineProperty$1(_ref5, Path, val.valPath), _defineProperty$1(_ref5, "val", val.val), _ref5;
|
|
33342
33342
|
}
|
|
33343
33343
|
}
|
|
33344
33344
|
function hasOwn(obj, prop) {
|
|
33345
33345
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
33346
33346
|
}
|
|
33347
|
-
function _regeneratorRuntime() {
|
|
33348
|
-
_regeneratorRuntime = function() {
|
|
33347
|
+
function _regeneratorRuntime$1() {
|
|
33348
|
+
_regeneratorRuntime$1 = function() {
|
|
33349
33349
|
return e;
|
|
33350
33350
|
};
|
|
33351
33351
|
var t, e = {}, r2 = Object.prototype, n = r2.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r3) {
|
|
@@ -33655,7 +33655,7 @@ function _regeneratorRuntime() {
|
|
|
33655
33655
|
}
|
|
33656
33656
|
}, e;
|
|
33657
33657
|
}
|
|
33658
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
33658
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
33659
33659
|
try {
|
|
33660
33660
|
var info = gen[key](arg);
|
|
33661
33661
|
var value = info.value;
|
|
@@ -33669,25 +33669,25 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
33669
33669
|
Promise.resolve(value).then(_next, _throw);
|
|
33670
33670
|
}
|
|
33671
33671
|
}
|
|
33672
|
-
function _asyncToGenerator(fn) {
|
|
33672
|
+
function _asyncToGenerator$1(fn) {
|
|
33673
33673
|
return function() {
|
|
33674
33674
|
var self = this, args = arguments;
|
|
33675
33675
|
return new Promise(function(resolve, reject) {
|
|
33676
33676
|
var gen = fn.apply(self, args);
|
|
33677
33677
|
function _next(value) {
|
|
33678
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33678
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
33679
33679
|
}
|
|
33680
33680
|
function _throw(err2) {
|
|
33681
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err2);
|
|
33681
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err2);
|
|
33682
33682
|
}
|
|
33683
33683
|
_next(void 0);
|
|
33684
33684
|
});
|
|
33685
33685
|
};
|
|
33686
33686
|
}
|
|
33687
33687
|
var getSHA256Hash = /* @__PURE__ */ function() {
|
|
33688
|
-
var _ref = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(bits) {
|
|
33688
|
+
var _ref = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(bits) {
|
|
33689
33689
|
var hashBuffer, hashArray, hash;
|
|
33690
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33690
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
33691
33691
|
while (1)
|
|
33692
33692
|
switch (_context.prev = _context.next) {
|
|
33693
33693
|
case 0:
|
|
@@ -33733,9 +33733,9 @@ var ValApi = /* @__PURE__ */ function() {
|
|
|
33733
33733
|
}, {
|
|
33734
33734
|
key: "getPatches",
|
|
33735
33735
|
value: function() {
|
|
33736
|
-
var _getPatches = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(_ref) {
|
|
33736
|
+
var _getPatches = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee(_ref) {
|
|
33737
33737
|
var patchIds, headers, patchIdsParam;
|
|
33738
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33738
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
33739
33739
|
while (1)
|
|
33740
33740
|
switch (_context.prev = _context.next) {
|
|
33741
33741
|
case 0:
|
|
@@ -33769,7 +33769,7 @@ var ValApi = /* @__PURE__ */ function() {
|
|
|
33769
33769
|
"Content-Type": "application/json"
|
|
33770
33770
|
},
|
|
33771
33771
|
method: "POST",
|
|
33772
|
-
body: JSON.stringify(_defineProperty({}, moduleId, patches))
|
|
33772
|
+
body: JSON.stringify(_defineProperty$1({}, moduleId, patches))
|
|
33773
33773
|
}).then(function(res) {
|
|
33774
33774
|
return parse$1(res);
|
|
33775
33775
|
});
|
|
@@ -33802,8 +33802,8 @@ function parse$1(_x2) {
|
|
|
33802
33802
|
return _parse.apply(this, arguments);
|
|
33803
33803
|
}
|
|
33804
33804
|
function _parse() {
|
|
33805
|
-
_parse = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(res) {
|
|
33806
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
33805
|
+
_parse = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2(res) {
|
|
33806
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
|
|
33807
33807
|
while (1)
|
|
33808
33808
|
switch (_context2.prev = _context2.next) {
|
|
33809
33809
|
case 0:
|
|
@@ -37798,26 +37798,6 @@ Tree.Node = ({
|
|
|
37798
37798
|
}) })
|
|
37799
37799
|
] });
|
|
37800
37800
|
};
|
|
37801
|
-
const MIME_TYPE_REGEX = /^data:(image\/(png|jpeg|jpg|gif|webp|bmp|tiff|ico|svg\+xml));base64,/;
|
|
37802
|
-
function getMimeType(base64Url) {
|
|
37803
|
-
const match = MIME_TYPE_REGEX.exec(base64Url);
|
|
37804
|
-
if (match && match[1]) {
|
|
37805
|
-
return match[1];
|
|
37806
|
-
}
|
|
37807
|
-
return;
|
|
37808
|
-
}
|
|
37809
|
-
function mimeTypeToFileExt(mimeType) {
|
|
37810
|
-
if (mimeType === "image/svg+xml") {
|
|
37811
|
-
return "svg";
|
|
37812
|
-
}
|
|
37813
|
-
if (mimeType === "image/vnd.microsoft.icon") {
|
|
37814
|
-
return "ico";
|
|
37815
|
-
}
|
|
37816
|
-
if (mimeType.startsWith("image/")) {
|
|
37817
|
-
return mimeType.slice("image/".length);
|
|
37818
|
-
}
|
|
37819
|
-
return mimeType;
|
|
37820
|
-
}
|
|
37821
37801
|
function _getDefaults() {
|
|
37822
37802
|
return {
|
|
37823
37803
|
async: false,
|
|
@@ -39806,192 +39786,1158 @@ marked.walkTokens;
|
|
|
39806
39786
|
marked.parseInline;
|
|
39807
39787
|
_Parser.parse;
|
|
39808
39788
|
const lexer = _Lexer.lex;
|
|
39809
|
-
|
|
39810
|
-
|
|
39811
|
-
|
|
39812
|
-
|
|
39813
|
-
var
|
|
39814
|
-
|
|
39815
|
-
|
|
39816
|
-
|
|
39817
|
-
|
|
39818
|
-
|
|
39819
|
-
|
|
39820
|
-
|
|
39821
|
-
|
|
39822
|
-
}
|
|
39823
|
-
|
|
39824
|
-
|
|
39825
|
-
|
|
39826
|
-
|
|
39827
|
-
|
|
39828
|
-
|
|
39829
|
-
|
|
39830
|
-
|
|
39831
|
-
|
|
39832
|
-
|
|
39833
|
-
|
|
39834
|
-
|
|
39835
|
-
|
|
39836
|
-
|
|
39837
|
-
|
|
39838
|
-
|
|
39839
|
-
|
|
39840
|
-
|
|
39841
|
-
|
|
39842
|
-
|
|
39843
|
-
|
|
39844
|
-
|
|
39845
|
-
|
|
39846
|
-
|
|
39847
|
-
|
|
39848
|
-
|
|
39849
|
-
|
|
39850
|
-
|
|
39851
|
-
|
|
39852
|
-
|
|
39853
|
-
|
|
39854
|
-
|
|
39855
|
-
|
|
39856
|
-
|
|
39857
|
-
|
|
39858
|
-
|
|
39859
|
-
|
|
39860
|
-
|
|
39861
|
-
|
|
39862
|
-
|
|
39863
|
-
|
|
39864
|
-
|
|
39865
|
-
|
|
39866
|
-
|
|
39867
|
-
|
|
39868
|
-
|
|
39869
|
-
});
|
|
39870
|
-
} else if (token.type === "list_item") {
|
|
39871
|
-
children.push({
|
|
39872
|
-
tag: "li",
|
|
39873
|
-
children: parseTokens(
|
|
39874
|
-
token.tokens ? token.tokens : [],
|
|
39875
|
-
sourceNodes,
|
|
39876
|
-
0,
|
|
39877
|
-
true
|
|
39878
|
-
).children
|
|
39789
|
+
function _regeneratorRuntime() {
|
|
39790
|
+
_regeneratorRuntime = function() {
|
|
39791
|
+
return e;
|
|
39792
|
+
};
|
|
39793
|
+
var t, e = {}, r2 = Object.prototype, n = r2.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r3) {
|
|
39794
|
+
t2[e2] = r3.value;
|
|
39795
|
+
}, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag";
|
|
39796
|
+
function define(t2, e2, r3) {
|
|
39797
|
+
return Object.defineProperty(t2, e2, {
|
|
39798
|
+
value: r3,
|
|
39799
|
+
enumerable: true,
|
|
39800
|
+
configurable: true,
|
|
39801
|
+
writable: true
|
|
39802
|
+
}), t2[e2];
|
|
39803
|
+
}
|
|
39804
|
+
try {
|
|
39805
|
+
define({}, "");
|
|
39806
|
+
} catch (t2) {
|
|
39807
|
+
define = function(t3, e2, r3) {
|
|
39808
|
+
return t3[e2] = r3;
|
|
39809
|
+
};
|
|
39810
|
+
}
|
|
39811
|
+
function wrap(t2, e2, r3, n2) {
|
|
39812
|
+
var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c2 = new Context(n2 || []);
|
|
39813
|
+
return o(a2, "_invoke", {
|
|
39814
|
+
value: makeInvokeMethod(t2, r3, c2)
|
|
39815
|
+
}), a2;
|
|
39816
|
+
}
|
|
39817
|
+
function tryCatch(t2, e2, r3) {
|
|
39818
|
+
try {
|
|
39819
|
+
return {
|
|
39820
|
+
type: "normal",
|
|
39821
|
+
arg: t2.call(e2, r3)
|
|
39822
|
+
};
|
|
39823
|
+
} catch (t3) {
|
|
39824
|
+
return {
|
|
39825
|
+
type: "throw",
|
|
39826
|
+
arg: t3
|
|
39827
|
+
};
|
|
39828
|
+
}
|
|
39829
|
+
}
|
|
39830
|
+
e.wrap = wrap;
|
|
39831
|
+
var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {};
|
|
39832
|
+
function Generator() {
|
|
39833
|
+
}
|
|
39834
|
+
function GeneratorFunction() {
|
|
39835
|
+
}
|
|
39836
|
+
function GeneratorFunctionPrototype() {
|
|
39837
|
+
}
|
|
39838
|
+
var p = {};
|
|
39839
|
+
define(p, a, function() {
|
|
39840
|
+
return this;
|
|
39841
|
+
});
|
|
39842
|
+
var d = Object.getPrototypeOf, v = d && d(d(values([])));
|
|
39843
|
+
v && v !== r2 && n.call(v, a) && (p = v);
|
|
39844
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
39845
|
+
function defineIteratorMethods(t2) {
|
|
39846
|
+
["next", "throw", "return"].forEach(function(e2) {
|
|
39847
|
+
define(t2, e2, function(t3) {
|
|
39848
|
+
return this._invoke(e2, t3);
|
|
39879
39849
|
});
|
|
39880
|
-
}
|
|
39881
|
-
|
|
39882
|
-
|
|
39883
|
-
|
|
39884
|
-
|
|
39850
|
+
});
|
|
39851
|
+
}
|
|
39852
|
+
function AsyncIterator(t2, e2) {
|
|
39853
|
+
function invoke(r4, o2, i2, a2) {
|
|
39854
|
+
var c2 = tryCatch(t2[r4], t2, o2);
|
|
39855
|
+
if ("throw" !== c2.type) {
|
|
39856
|
+
var u2 = c2.arg, h2 = u2.value;
|
|
39857
|
+
return h2 && "object" == typeof h2 && n.call(h2, "__await") ? e2.resolve(h2.__await).then(function(t3) {
|
|
39858
|
+
invoke("next", t3, i2, a2);
|
|
39859
|
+
}, function(t3) {
|
|
39860
|
+
invoke("throw", t3, i2, a2);
|
|
39861
|
+
}) : e2.resolve(h2).then(function(t3) {
|
|
39862
|
+
u2.value = t3, i2(u2);
|
|
39863
|
+
}, function(t3) {
|
|
39864
|
+
return invoke("throw", t3, i2, a2);
|
|
39865
|
+
});
|
|
39885
39866
|
}
|
|
39886
|
-
|
|
39887
|
-
|
|
39888
|
-
|
|
39889
|
-
|
|
39890
|
-
|
|
39891
|
-
|
|
39892
|
-
|
|
39893
|
-
|
|
39894
|
-
);
|
|
39895
|
-
}
|
|
39896
|
-
const { children: subChildren, cursor: subCursor } = parseTokens(
|
|
39897
|
-
tokens.map((token2) => {
|
|
39898
|
-
if (token2.type === "link" || token2.type === "list") {
|
|
39899
|
-
return {
|
|
39900
|
-
type: "text",
|
|
39901
|
-
raw: token2.raw,
|
|
39902
|
-
text: token2.raw
|
|
39903
|
-
};
|
|
39904
|
-
}
|
|
39905
|
-
return token2;
|
|
39906
|
-
}),
|
|
39907
|
-
sourceNodes,
|
|
39908
|
-
cursor + 1
|
|
39909
|
-
);
|
|
39910
|
-
const sourceNode = sourceNodes[number];
|
|
39911
|
-
if (sourceNode._type === "link") {
|
|
39912
|
-
children.push({
|
|
39913
|
-
tag: "a",
|
|
39914
|
-
href: sourceNode.href,
|
|
39915
|
-
children: subChildren
|
|
39916
|
-
});
|
|
39917
|
-
} else if (sourceNode._type === "file") {
|
|
39918
|
-
children.push({
|
|
39919
|
-
tag: "img",
|
|
39920
|
-
src: Internal.convertFileSource(sourceNode).url,
|
|
39921
|
-
width: (_a = sourceNode.metadata) == null ? void 0 : _a.width,
|
|
39922
|
-
height: (_b = sourceNode.metadata) == null ? void 0 : _b.height,
|
|
39923
|
-
children: []
|
|
39867
|
+
a2(c2.arg);
|
|
39868
|
+
}
|
|
39869
|
+
var r3;
|
|
39870
|
+
o(this, "_invoke", {
|
|
39871
|
+
value: function(t3, n2) {
|
|
39872
|
+
function callInvokeWithMethodAndArg() {
|
|
39873
|
+
return new e2(function(e3, r4) {
|
|
39874
|
+
invoke(t3, n2, e3, r4);
|
|
39924
39875
|
});
|
|
39925
39876
|
}
|
|
39926
|
-
|
|
39927
|
-
}
|
|
39928
|
-
const br_html_regex = /<br\s*\/?>/gi;
|
|
39929
|
-
if (token.text.trim().match(br_html_regex)) {
|
|
39930
|
-
children.push({
|
|
39931
|
-
tag: "br",
|
|
39932
|
-
children: []
|
|
39933
|
-
});
|
|
39934
|
-
}
|
|
39935
|
-
} else if (token.type === "link") {
|
|
39936
|
-
if (token.raw === token.href) {
|
|
39937
|
-
children.push(token.raw);
|
|
39938
|
-
} else {
|
|
39939
|
-
children.push({
|
|
39940
|
-
tag: "a",
|
|
39941
|
-
href: token.href,
|
|
39942
|
-
children: parseTokens(
|
|
39943
|
-
token.tokens ? token.tokens : [],
|
|
39944
|
-
sourceNodes,
|
|
39945
|
-
0
|
|
39946
|
-
).children
|
|
39947
|
-
});
|
|
39877
|
+
return r3 = r3 ? r3.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
39948
39878
|
}
|
|
39949
|
-
}
|
|
39950
|
-
children.push({
|
|
39951
|
-
tag: "br",
|
|
39952
|
-
children: []
|
|
39953
|
-
});
|
|
39954
|
-
} else {
|
|
39955
|
-
console.error(
|
|
39956
|
-
`Could not parse markdown: unsupported token type: ${token.type}. Found: ${token.raw}`
|
|
39957
|
-
);
|
|
39958
|
-
}
|
|
39959
|
-
cursor++;
|
|
39879
|
+
});
|
|
39960
39880
|
}
|
|
39961
|
-
|
|
39962
|
-
|
|
39963
|
-
function
|
|
39964
|
-
|
|
39965
|
-
|
|
39966
|
-
|
|
39967
|
-
|
|
39968
|
-
|
|
39969
|
-
|
|
39970
|
-
|
|
39971
|
-
|
|
39972
|
-
|
|
39973
|
-
|
|
39974
|
-
|
|
39975
|
-
|
|
39976
|
-
|
|
39977
|
-
|
|
39978
|
-
|
|
39979
|
-
|
|
39980
|
-
|
|
39981
|
-
|
|
39982
|
-
|
|
39983
|
-
|
|
39984
|
-
|
|
39985
|
-
|
|
39986
|
-
|
|
39987
|
-
|
|
39988
|
-
|
|
39989
|
-
|
|
39881
|
+
function makeInvokeMethod(e2, r3, n2) {
|
|
39882
|
+
var o2 = h;
|
|
39883
|
+
return function(i2, a2) {
|
|
39884
|
+
if (o2 === f)
|
|
39885
|
+
throw new Error("Generator is already running");
|
|
39886
|
+
if (o2 === s) {
|
|
39887
|
+
if ("throw" === i2)
|
|
39888
|
+
throw a2;
|
|
39889
|
+
return {
|
|
39890
|
+
value: t,
|
|
39891
|
+
done: true
|
|
39892
|
+
};
|
|
39893
|
+
}
|
|
39894
|
+
for (n2.method = i2, n2.arg = a2; ; ) {
|
|
39895
|
+
var c2 = n2.delegate;
|
|
39896
|
+
if (c2) {
|
|
39897
|
+
var u2 = maybeInvokeDelegate(c2, n2);
|
|
39898
|
+
if (u2) {
|
|
39899
|
+
if (u2 === y)
|
|
39900
|
+
continue;
|
|
39901
|
+
return u2;
|
|
39902
|
+
}
|
|
39903
|
+
}
|
|
39904
|
+
if ("next" === n2.method)
|
|
39905
|
+
n2.sent = n2._sent = n2.arg;
|
|
39906
|
+
else if ("throw" === n2.method) {
|
|
39907
|
+
if (o2 === h)
|
|
39908
|
+
throw o2 = s, n2.arg;
|
|
39909
|
+
n2.dispatchException(n2.arg);
|
|
39910
|
+
} else
|
|
39911
|
+
"return" === n2.method && n2.abrupt("return", n2.arg);
|
|
39912
|
+
o2 = f;
|
|
39913
|
+
var p2 = tryCatch(e2, r3, n2);
|
|
39914
|
+
if ("normal" === p2.type) {
|
|
39915
|
+
if (o2 = n2.done ? s : l, p2.arg === y)
|
|
39916
|
+
continue;
|
|
39917
|
+
return {
|
|
39918
|
+
value: p2.arg,
|
|
39919
|
+
done: n2.done
|
|
39920
|
+
};
|
|
39921
|
+
}
|
|
39922
|
+
"throw" === p2.type && (o2 = s, n2.method = "throw", n2.arg = p2.arg);
|
|
39923
|
+
}
|
|
39924
|
+
};
|
|
39925
|
+
}
|
|
39926
|
+
function maybeInvokeDelegate(e2, r3) {
|
|
39927
|
+
var n2 = r3.method, o2 = e2.iterator[n2];
|
|
39928
|
+
if (o2 === t)
|
|
39929
|
+
return r3.delegate = null, "throw" === n2 && e2.iterator.return && (r3.method = "return", r3.arg = t, maybeInvokeDelegate(e2, r3), "throw" === r3.method) || "return" !== n2 && (r3.method = "throw", r3.arg = new TypeError("The iterator does not provide a '" + n2 + "' method")), y;
|
|
39930
|
+
var i2 = tryCatch(o2, e2.iterator, r3.arg);
|
|
39931
|
+
if ("throw" === i2.type)
|
|
39932
|
+
return r3.method = "throw", r3.arg = i2.arg, r3.delegate = null, y;
|
|
39933
|
+
var a2 = i2.arg;
|
|
39934
|
+
return a2 ? a2.done ? (r3[e2.resultName] = a2.value, r3.next = e2.nextLoc, "return" !== r3.method && (r3.method = "next", r3.arg = t), r3.delegate = null, y) : a2 : (r3.method = "throw", r3.arg = new TypeError("iterator result is not an object"), r3.delegate = null, y);
|
|
39935
|
+
}
|
|
39936
|
+
function pushTryEntry(t2) {
|
|
39937
|
+
var e2 = {
|
|
39938
|
+
tryLoc: t2[0]
|
|
39939
|
+
};
|
|
39940
|
+
1 in t2 && (e2.catchLoc = t2[1]), 2 in t2 && (e2.finallyLoc = t2[2], e2.afterLoc = t2[3]), this.tryEntries.push(e2);
|
|
39941
|
+
}
|
|
39942
|
+
function resetTryEntry(t2) {
|
|
39943
|
+
var e2 = t2.completion || {};
|
|
39944
|
+
e2.type = "normal", delete e2.arg, t2.completion = e2;
|
|
39945
|
+
}
|
|
39946
|
+
function Context(t2) {
|
|
39947
|
+
this.tryEntries = [{
|
|
39948
|
+
tryLoc: "root"
|
|
39949
|
+
}], t2.forEach(pushTryEntry, this), this.reset(true);
|
|
39950
|
+
}
|
|
39951
|
+
function values(e2) {
|
|
39952
|
+
if (e2 || "" === e2) {
|
|
39953
|
+
var r3 = e2[a];
|
|
39954
|
+
if (r3)
|
|
39955
|
+
return r3.call(e2);
|
|
39956
|
+
if ("function" == typeof e2.next)
|
|
39957
|
+
return e2;
|
|
39958
|
+
if (!isNaN(e2.length)) {
|
|
39959
|
+
var o2 = -1, i2 = function next() {
|
|
39960
|
+
for (; ++o2 < e2.length; )
|
|
39961
|
+
if (n.call(e2, o2))
|
|
39962
|
+
return next.value = e2[o2], next.done = false, next;
|
|
39963
|
+
return next.value = t, next.done = true, next;
|
|
39964
|
+
};
|
|
39965
|
+
return i2.next = i2;
|
|
39966
|
+
}
|
|
39967
|
+
}
|
|
39968
|
+
throw new TypeError(typeof e2 + " is not iterable");
|
|
39969
|
+
}
|
|
39970
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
39971
|
+
value: GeneratorFunctionPrototype,
|
|
39972
|
+
configurable: true
|
|
39973
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
39974
|
+
value: GeneratorFunction,
|
|
39975
|
+
configurable: true
|
|
39976
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function(t2) {
|
|
39977
|
+
var e2 = "function" == typeof t2 && t2.constructor;
|
|
39978
|
+
return !!e2 && (e2 === GeneratorFunction || "GeneratorFunction" === (e2.displayName || e2.name));
|
|
39979
|
+
}, e.mark = function(t2) {
|
|
39980
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2;
|
|
39981
|
+
}, e.awrap = function(t2) {
|
|
39982
|
+
return {
|
|
39983
|
+
__await: t2
|
|
39984
|
+
};
|
|
39985
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function() {
|
|
39986
|
+
return this;
|
|
39987
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function(t2, r3, n2, o2, i2) {
|
|
39988
|
+
void 0 === i2 && (i2 = Promise);
|
|
39989
|
+
var a2 = new AsyncIterator(wrap(t2, r3, n2, o2), i2);
|
|
39990
|
+
return e.isGeneratorFunction(r3) ? a2 : a2.next().then(function(t3) {
|
|
39991
|
+
return t3.done ? t3.value : a2.next();
|
|
39992
|
+
});
|
|
39993
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function() {
|
|
39994
|
+
return this;
|
|
39995
|
+
}), define(g, "toString", function() {
|
|
39996
|
+
return "[object Generator]";
|
|
39997
|
+
}), e.keys = function(t2) {
|
|
39998
|
+
var e2 = Object(t2), r3 = [];
|
|
39999
|
+
for (var n2 in e2)
|
|
40000
|
+
r3.push(n2);
|
|
40001
|
+
return r3.reverse(), function next() {
|
|
40002
|
+
for (; r3.length; ) {
|
|
40003
|
+
var t3 = r3.pop();
|
|
40004
|
+
if (t3 in e2)
|
|
40005
|
+
return next.value = t3, next.done = false, next;
|
|
40006
|
+
}
|
|
40007
|
+
return next.done = true, next;
|
|
40008
|
+
};
|
|
40009
|
+
}, e.values = values, Context.prototype = {
|
|
40010
|
+
constructor: Context,
|
|
40011
|
+
reset: function(e2) {
|
|
40012
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e2)
|
|
40013
|
+
for (var r3 in this)
|
|
40014
|
+
"t" === r3.charAt(0) && n.call(this, r3) && !isNaN(+r3.slice(1)) && (this[r3] = t);
|
|
40015
|
+
},
|
|
40016
|
+
stop: function() {
|
|
40017
|
+
this.done = true;
|
|
40018
|
+
var t2 = this.tryEntries[0].completion;
|
|
40019
|
+
if ("throw" === t2.type)
|
|
40020
|
+
throw t2.arg;
|
|
40021
|
+
return this.rval;
|
|
40022
|
+
},
|
|
40023
|
+
dispatchException: function(e2) {
|
|
40024
|
+
if (this.done)
|
|
40025
|
+
throw e2;
|
|
40026
|
+
var r3 = this;
|
|
40027
|
+
function handle(n2, o3) {
|
|
40028
|
+
return a2.type = "throw", a2.arg = e2, r3.next = n2, o3 && (r3.method = "next", r3.arg = t), !!o3;
|
|
40029
|
+
}
|
|
40030
|
+
for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) {
|
|
40031
|
+
var i2 = this.tryEntries[o2], a2 = i2.completion;
|
|
40032
|
+
if ("root" === i2.tryLoc)
|
|
40033
|
+
return handle("end");
|
|
40034
|
+
if (i2.tryLoc <= this.prev) {
|
|
40035
|
+
var c2 = n.call(i2, "catchLoc"), u2 = n.call(i2, "finallyLoc");
|
|
40036
|
+
if (c2 && u2) {
|
|
40037
|
+
if (this.prev < i2.catchLoc)
|
|
40038
|
+
return handle(i2.catchLoc, true);
|
|
40039
|
+
if (this.prev < i2.finallyLoc)
|
|
40040
|
+
return handle(i2.finallyLoc);
|
|
40041
|
+
} else if (c2) {
|
|
40042
|
+
if (this.prev < i2.catchLoc)
|
|
40043
|
+
return handle(i2.catchLoc, true);
|
|
40044
|
+
} else {
|
|
40045
|
+
if (!u2)
|
|
40046
|
+
throw new Error("try statement without catch or finally");
|
|
40047
|
+
if (this.prev < i2.finallyLoc)
|
|
40048
|
+
return handle(i2.finallyLoc);
|
|
40049
|
+
}
|
|
40050
|
+
}
|
|
40051
|
+
}
|
|
40052
|
+
},
|
|
40053
|
+
abrupt: function(t2, e2) {
|
|
40054
|
+
for (var r3 = this.tryEntries.length - 1; r3 >= 0; --r3) {
|
|
40055
|
+
var o2 = this.tryEntries[r3];
|
|
40056
|
+
if (o2.tryLoc <= this.prev && n.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) {
|
|
40057
|
+
var i2 = o2;
|
|
40058
|
+
break;
|
|
40059
|
+
}
|
|
40060
|
+
}
|
|
40061
|
+
i2 && ("break" === t2 || "continue" === t2) && i2.tryLoc <= e2 && e2 <= i2.finallyLoc && (i2 = null);
|
|
40062
|
+
var a2 = i2 ? i2.completion : {};
|
|
40063
|
+
return a2.type = t2, a2.arg = e2, i2 ? (this.method = "next", this.next = i2.finallyLoc, y) : this.complete(a2);
|
|
40064
|
+
},
|
|
40065
|
+
complete: function(t2, e2) {
|
|
40066
|
+
if ("throw" === t2.type)
|
|
40067
|
+
throw t2.arg;
|
|
40068
|
+
return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e2 && (this.next = e2), y;
|
|
40069
|
+
},
|
|
40070
|
+
finish: function(t2) {
|
|
40071
|
+
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
|
|
40072
|
+
var r3 = this.tryEntries[e2];
|
|
40073
|
+
if (r3.finallyLoc === t2)
|
|
40074
|
+
return this.complete(r3.completion, r3.afterLoc), resetTryEntry(r3), y;
|
|
40075
|
+
}
|
|
40076
|
+
},
|
|
40077
|
+
catch: function(t2) {
|
|
40078
|
+
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
|
|
40079
|
+
var r3 = this.tryEntries[e2];
|
|
40080
|
+
if (r3.tryLoc === t2) {
|
|
40081
|
+
var n2 = r3.completion;
|
|
40082
|
+
if ("throw" === n2.type) {
|
|
40083
|
+
var o2 = n2.arg;
|
|
40084
|
+
resetTryEntry(r3);
|
|
40085
|
+
}
|
|
40086
|
+
return o2;
|
|
40087
|
+
}
|
|
40088
|
+
}
|
|
40089
|
+
throw new Error("illegal catch attempt");
|
|
40090
|
+
},
|
|
40091
|
+
delegateYield: function(e2, r3, n2) {
|
|
40092
|
+
return this.delegate = {
|
|
40093
|
+
iterator: values(e2),
|
|
40094
|
+
resultName: r3,
|
|
40095
|
+
nextLoc: n2
|
|
40096
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
40097
|
+
}
|
|
40098
|
+
}, e;
|
|
40099
|
+
}
|
|
40100
|
+
function _arrayLikeToArray(arr, len) {
|
|
40101
|
+
if (len == null || len > arr.length)
|
|
40102
|
+
len = arr.length;
|
|
40103
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
40104
|
+
arr2[i] = arr[i];
|
|
40105
|
+
return arr2;
|
|
40106
|
+
}
|
|
40107
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
40108
|
+
if (!o)
|
|
40109
|
+
return;
|
|
40110
|
+
if (typeof o === "string")
|
|
40111
|
+
return _arrayLikeToArray(o, minLen);
|
|
40112
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
40113
|
+
if (n === "Object" && o.constructor)
|
|
40114
|
+
n = o.constructor.name;
|
|
40115
|
+
if (n === "Map" || n === "Set")
|
|
40116
|
+
return Array.from(o);
|
|
40117
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
40118
|
+
return _arrayLikeToArray(o, minLen);
|
|
40119
|
+
}
|
|
40120
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
40121
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
40122
|
+
if (!it) {
|
|
40123
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
40124
|
+
if (it)
|
|
40125
|
+
o = it;
|
|
40126
|
+
var i = 0;
|
|
40127
|
+
var F = function() {
|
|
40128
|
+
};
|
|
40129
|
+
return {
|
|
40130
|
+
s: F,
|
|
40131
|
+
n: function() {
|
|
40132
|
+
if (i >= o.length)
|
|
40133
|
+
return {
|
|
40134
|
+
done: true
|
|
40135
|
+
};
|
|
40136
|
+
return {
|
|
40137
|
+
done: false,
|
|
40138
|
+
value: o[i++]
|
|
40139
|
+
};
|
|
40140
|
+
},
|
|
40141
|
+
e: function(e) {
|
|
40142
|
+
throw e;
|
|
40143
|
+
},
|
|
40144
|
+
f: F
|
|
40145
|
+
};
|
|
40146
|
+
}
|
|
40147
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
40148
|
+
}
|
|
40149
|
+
var normalCompletion = true, didErr = false, err2;
|
|
40150
|
+
return {
|
|
40151
|
+
s: function() {
|
|
40152
|
+
it = it.call(o);
|
|
40153
|
+
},
|
|
40154
|
+
n: function() {
|
|
40155
|
+
var step = it.next();
|
|
40156
|
+
normalCompletion = step.done;
|
|
40157
|
+
return step;
|
|
40158
|
+
},
|
|
40159
|
+
e: function(e) {
|
|
40160
|
+
didErr = true;
|
|
40161
|
+
err2 = e;
|
|
40162
|
+
},
|
|
40163
|
+
f: function() {
|
|
40164
|
+
try {
|
|
40165
|
+
if (!normalCompletion && it.return != null)
|
|
40166
|
+
it.return();
|
|
40167
|
+
} finally {
|
|
40168
|
+
if (didErr)
|
|
40169
|
+
throw err2;
|
|
40170
|
+
}
|
|
40171
|
+
}
|
|
40172
|
+
};
|
|
40173
|
+
}
|
|
40174
|
+
function _toPrimitive(input, hint) {
|
|
40175
|
+
if (typeof input !== "object" || input === null)
|
|
40176
|
+
return input;
|
|
40177
|
+
var prim = input[Symbol.toPrimitive];
|
|
40178
|
+
if (prim !== void 0) {
|
|
40179
|
+
var res = prim.call(input, hint || "default");
|
|
40180
|
+
if (typeof res !== "object")
|
|
40181
|
+
return res;
|
|
40182
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
40183
|
+
}
|
|
40184
|
+
return (hint === "string" ? String : Number)(input);
|
|
40185
|
+
}
|
|
40186
|
+
function _toPropertyKey(arg) {
|
|
40187
|
+
var key = _toPrimitive(arg, "string");
|
|
40188
|
+
return typeof key === "symbol" ? key : String(key);
|
|
40189
|
+
}
|
|
40190
|
+
function _defineProperty(obj, key, value) {
|
|
40191
|
+
key = _toPropertyKey(key);
|
|
40192
|
+
if (key in obj) {
|
|
40193
|
+
Object.defineProperty(obj, key, {
|
|
40194
|
+
value,
|
|
40195
|
+
enumerable: true,
|
|
40196
|
+
configurable: true,
|
|
40197
|
+
writable: true
|
|
40198
|
+
});
|
|
40199
|
+
} else {
|
|
40200
|
+
obj[key] = value;
|
|
40201
|
+
}
|
|
40202
|
+
return obj;
|
|
40203
|
+
}
|
|
40204
|
+
function _arrayWithHoles(arr) {
|
|
40205
|
+
if (Array.isArray(arr))
|
|
40206
|
+
return arr;
|
|
40207
|
+
}
|
|
40208
|
+
function _iterableToArrayLimit(r2, l) {
|
|
40209
|
+
var t = null == r2 ? null : "undefined" != typeof Symbol && r2[Symbol.iterator] || r2["@@iterator"];
|
|
40210
|
+
if (null != t) {
|
|
40211
|
+
var e, n, i, u, a = [], f = true, o = false;
|
|
40212
|
+
try {
|
|
40213
|
+
if (i = (t = t.call(r2)).next, 0 === l) {
|
|
40214
|
+
if (Object(t) !== t)
|
|
40215
|
+
return;
|
|
40216
|
+
f = false;
|
|
40217
|
+
} else
|
|
40218
|
+
for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true)
|
|
40219
|
+
;
|
|
40220
|
+
} catch (r3) {
|
|
40221
|
+
o = true, n = r3;
|
|
40222
|
+
} finally {
|
|
40223
|
+
try {
|
|
40224
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u))
|
|
40225
|
+
return;
|
|
40226
|
+
} finally {
|
|
40227
|
+
if (o)
|
|
40228
|
+
throw n;
|
|
40229
|
+
}
|
|
40230
|
+
}
|
|
40231
|
+
return a;
|
|
40232
|
+
}
|
|
40233
|
+
}
|
|
40234
|
+
function _nonIterableRest() {
|
|
40235
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
40236
|
+
}
|
|
40237
|
+
function _slicedToArray(arr, i) {
|
|
40238
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
40239
|
+
}
|
|
40240
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
40241
|
+
try {
|
|
40242
|
+
var info = gen[key](arg);
|
|
40243
|
+
var value = info.value;
|
|
40244
|
+
} catch (error) {
|
|
40245
|
+
reject(error);
|
|
40246
|
+
return;
|
|
40247
|
+
}
|
|
40248
|
+
if (info.done) {
|
|
40249
|
+
resolve(value);
|
|
40250
|
+
} else {
|
|
40251
|
+
Promise.resolve(value).then(_next, _throw);
|
|
40252
|
+
}
|
|
40253
|
+
}
|
|
40254
|
+
function _asyncToGenerator(fn) {
|
|
40255
|
+
return function() {
|
|
40256
|
+
var self = this, args = arguments;
|
|
40257
|
+
return new Promise(function(resolve, reject) {
|
|
40258
|
+
var gen = fn.apply(self, args);
|
|
40259
|
+
function _next(value) {
|
|
40260
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
40261
|
+
}
|
|
40262
|
+
function _throw(err2) {
|
|
40263
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err2);
|
|
40264
|
+
}
|
|
40265
|
+
_next(void 0);
|
|
40266
|
+
});
|
|
40267
|
+
};
|
|
40268
|
+
}
|
|
40269
|
+
function _arrayWithoutHoles(arr) {
|
|
40270
|
+
if (Array.isArray(arr))
|
|
40271
|
+
return _arrayLikeToArray(arr);
|
|
40272
|
+
}
|
|
40273
|
+
function _iterableToArray(iter) {
|
|
40274
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
40275
|
+
return Array.from(iter);
|
|
40276
|
+
}
|
|
40277
|
+
function _nonIterableSpread() {
|
|
40278
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
40279
|
+
}
|
|
40280
|
+
function _toConsumableArray(arr) {
|
|
40281
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
40282
|
+
}
|
|
40283
|
+
var MIME_TYPE_REGEX = /^data:(image\/(png|jpeg|jpg|gif|webp|bmp|tiff|ico|svg\+xml));base64,/;
|
|
40284
|
+
function getMimeType(base64Url) {
|
|
40285
|
+
var match = MIME_TYPE_REGEX.exec(base64Url);
|
|
40286
|
+
if (match && match[1]) {
|
|
40287
|
+
return match[1];
|
|
40288
|
+
}
|
|
40289
|
+
return;
|
|
40290
|
+
}
|
|
40291
|
+
function mimeTypeToFileExt(mimeType) {
|
|
40292
|
+
if (mimeType === "image/svg+xml") {
|
|
40293
|
+
return "svg";
|
|
40294
|
+
}
|
|
40295
|
+
if (mimeType === "image/vnd.microsoft.icon") {
|
|
40296
|
+
return "ico";
|
|
40297
|
+
}
|
|
40298
|
+
if (mimeType.startsWith("image/")) {
|
|
40299
|
+
return mimeType.slice("image/".length);
|
|
40300
|
+
}
|
|
40301
|
+
return mimeType;
|
|
40302
|
+
}
|
|
40303
|
+
var HeaderRegEx = /^h([\d+])$/;
|
|
40304
|
+
function lexicalToRichTextSource(node) {
|
|
40305
|
+
var markdownIRBlocks = node.children.map(createBlock);
|
|
40306
|
+
return fromIRToRichTextSource(markdownIRBlocks);
|
|
40307
|
+
}
|
|
40308
|
+
function createBlock(node) {
|
|
40309
|
+
if (node.type === "heading") {
|
|
40310
|
+
var _node$tag$match;
|
|
40311
|
+
var headingTag = "";
|
|
40312
|
+
var depth = Number((_node$tag$match = node.tag.match(HeaderRegEx)) === null || _node$tag$match === void 0 ? void 0 : _node$tag$match[1]);
|
|
40313
|
+
if (Number.isNaN(depth)) {
|
|
40314
|
+
throw new Error("Invalid header depth");
|
|
40315
|
+
}
|
|
40316
|
+
for (var i = 0; i < Number(depth); i++) {
|
|
40317
|
+
headingTag += "#";
|
|
40318
|
+
}
|
|
40319
|
+
var headingText = ["".concat(headingTag, " ")];
|
|
40320
|
+
return {
|
|
40321
|
+
type: "block",
|
|
40322
|
+
children: headingText.concat.apply(headingText, _toConsumableArray(node.children.map(transformLeafNode)))
|
|
40323
|
+
};
|
|
40324
|
+
} else if (node.type === "paragraph") {
|
|
40325
|
+
if (node.children.length === 0) {
|
|
40326
|
+
return {
|
|
40327
|
+
type: "block",
|
|
40328
|
+
children: ["<br />"]
|
|
40329
|
+
};
|
|
40330
|
+
}
|
|
40331
|
+
return {
|
|
40332
|
+
type: "block",
|
|
40333
|
+
children: node.children.map(function(child) {
|
|
40334
|
+
return transformLeafNode(child);
|
|
40335
|
+
})
|
|
40336
|
+
};
|
|
40337
|
+
} else if (node.type === "list") {
|
|
40338
|
+
return {
|
|
40339
|
+
type: "block",
|
|
40340
|
+
children: node.children.flatMap(function(child, i2) {
|
|
40341
|
+
return formatListItemNode(getListPrefix(node), child, 0, i2 === 0);
|
|
40342
|
+
})
|
|
40343
|
+
};
|
|
40344
|
+
} else {
|
|
40345
|
+
var exhaustiveCheck = node;
|
|
40346
|
+
throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
|
|
40347
|
+
}
|
|
40348
|
+
}
|
|
40349
|
+
function fromIRToRichTextSource(_x) {
|
|
40350
|
+
return _fromIRToRichTextSource.apply(this, arguments);
|
|
40351
|
+
}
|
|
40352
|
+
function _fromIRToRichTextSource() {
|
|
40353
|
+
_fromIRToRichTextSource = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(markdownIRBlocks) {
|
|
40354
|
+
var _ref4;
|
|
40355
|
+
var templateStrings, exprs, files, blockIdx, block2, _iterator, _step, child, exhaustiveCheck;
|
|
40356
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40357
|
+
while (1)
|
|
40358
|
+
switch (_context.prev = _context.next) {
|
|
40359
|
+
case 0:
|
|
40360
|
+
templateStrings = ["\n"];
|
|
40361
|
+
exprs = [];
|
|
40362
|
+
files = {};
|
|
40363
|
+
blockIdx = 0;
|
|
40364
|
+
case 4:
|
|
40365
|
+
if (!(blockIdx < markdownIRBlocks.length)) {
|
|
40366
|
+
_context.next = 44;
|
|
40367
|
+
break;
|
|
40368
|
+
}
|
|
40369
|
+
block2 = markdownIRBlocks[blockIdx];
|
|
40370
|
+
_iterator = _createForOfIteratorHelper(block2.children);
|
|
40371
|
+
_context.prev = 7;
|
|
40372
|
+
_iterator.s();
|
|
40373
|
+
case 9:
|
|
40374
|
+
if ((_step = _iterator.n()).done) {
|
|
40375
|
+
_context.next = 32;
|
|
40376
|
+
break;
|
|
40377
|
+
}
|
|
40378
|
+
child = _step.value;
|
|
40379
|
+
if (!(typeof child === "string")) {
|
|
40380
|
+
_context.next = 15;
|
|
40381
|
+
break;
|
|
40382
|
+
}
|
|
40383
|
+
templateStrings[templateStrings.length - 1] += child;
|
|
40384
|
+
_context.next = 30;
|
|
40385
|
+
break;
|
|
40386
|
+
case 15:
|
|
40387
|
+
if (!(child.type === "image")) {
|
|
40388
|
+
_context.next = 23;
|
|
40389
|
+
break;
|
|
40390
|
+
}
|
|
40391
|
+
_context.t0 = exprs;
|
|
40392
|
+
_context.next = 19;
|
|
40393
|
+
return fromLexicalImageNode(child, files);
|
|
40394
|
+
case 19:
|
|
40395
|
+
_context.t1 = _context.sent;
|
|
40396
|
+
_context.t0.push.call(_context.t0, _context.t1);
|
|
40397
|
+
_context.next = 29;
|
|
40398
|
+
break;
|
|
40399
|
+
case 23:
|
|
40400
|
+
if (!(child.type === "link")) {
|
|
40401
|
+
_context.next = 27;
|
|
40402
|
+
break;
|
|
40403
|
+
}
|
|
40404
|
+
exprs.push(fromLexicalLinkNode(child));
|
|
40405
|
+
_context.next = 29;
|
|
40406
|
+
break;
|
|
40407
|
+
case 27:
|
|
40408
|
+
exhaustiveCheck = child;
|
|
40409
|
+
throw new Error("Unexpected node type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
|
|
40410
|
+
case 29:
|
|
40411
|
+
templateStrings.push("");
|
|
40412
|
+
case 30:
|
|
40413
|
+
_context.next = 9;
|
|
40414
|
+
break;
|
|
40415
|
+
case 32:
|
|
40416
|
+
_context.next = 37;
|
|
40417
|
+
break;
|
|
40418
|
+
case 34:
|
|
40419
|
+
_context.prev = 34;
|
|
40420
|
+
_context.t2 = _context["catch"](7);
|
|
40421
|
+
_iterator.e(_context.t2);
|
|
40422
|
+
case 37:
|
|
40423
|
+
_context.prev = 37;
|
|
40424
|
+
_iterator.f();
|
|
40425
|
+
return _context.finish(37);
|
|
40426
|
+
case 40:
|
|
40427
|
+
if (blockIdx === markdownIRBlocks.length - 1) {
|
|
40428
|
+
templateStrings[templateStrings.length - 1] += "\n";
|
|
40429
|
+
} else {
|
|
40430
|
+
templateStrings[templateStrings.length - 1] += "\n\n";
|
|
40431
|
+
}
|
|
40432
|
+
case 41:
|
|
40433
|
+
blockIdx++;
|
|
40434
|
+
_context.next = 4;
|
|
40435
|
+
break;
|
|
40436
|
+
case 44:
|
|
40437
|
+
return _context.abrupt("return", (_ref4 = {}, _defineProperty(_ref4, VAL_EXTENSION, "richtext"), _defineProperty(_ref4, "templateStrings", templateStrings), _defineProperty(_ref4, "exprs", exprs), _defineProperty(_ref4, "files", files), _ref4));
|
|
40438
|
+
case 45:
|
|
40439
|
+
case "end":
|
|
40440
|
+
return _context.stop();
|
|
40441
|
+
}
|
|
40442
|
+
}, _callee, null, [[7, 34, 37, 40]]);
|
|
40443
|
+
}));
|
|
40444
|
+
return _fromIRToRichTextSource.apply(this, arguments);
|
|
40445
|
+
}
|
|
40446
|
+
function formatText(node) {
|
|
40447
|
+
var classes = typeof node.format === "number" ? fromLexicalFormat(node.format) : [];
|
|
40448
|
+
var text = node.text.trimStart();
|
|
40449
|
+
var prefixWS = node.text.length - text.length;
|
|
40450
|
+
text = text.trimEnd();
|
|
40451
|
+
var suffixWS = node.text.length - text.length - prefixWS;
|
|
40452
|
+
if (classes.includes("bold") && classes.includes("italic")) {
|
|
40453
|
+
text = "***".concat(text, "***");
|
|
40454
|
+
} else if (classes.includes("bold")) {
|
|
40455
|
+
text = "**".concat(text, "**");
|
|
40456
|
+
} else if (classes.includes("italic")) {
|
|
40457
|
+
text = "_".concat(text, "_");
|
|
40458
|
+
}
|
|
40459
|
+
if (classes.includes("line-through")) {
|
|
40460
|
+
text = "~~".concat(text, "~~");
|
|
40461
|
+
}
|
|
40462
|
+
return "".concat(" ".repeat(prefixWS)).concat(text).concat(" ".repeat(suffixWS));
|
|
40463
|
+
}
|
|
40464
|
+
function transformLeafNode(node) {
|
|
40465
|
+
if (node.type === "text") {
|
|
40466
|
+
return formatText(node);
|
|
40467
|
+
} else if (node.type === "linebreak") {
|
|
40468
|
+
return "\n";
|
|
40469
|
+
} else {
|
|
40470
|
+
return node;
|
|
40471
|
+
}
|
|
40472
|
+
}
|
|
40473
|
+
function formatListItemNode(listPrefix, node, indent) {
|
|
40474
|
+
var _node$children, _node$children$;
|
|
40475
|
+
var isFirstTopLevelListItem = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
|
|
40476
|
+
var newLine = isFirstTopLevelListItem ? "" : "\n";
|
|
40477
|
+
var prefix = ["".concat(newLine).concat(" ".repeat(indent)).concat(listPrefix)];
|
|
40478
|
+
if (((_node$children = node.children) === null || _node$children === void 0 ? void 0 : (_node$children$ = _node$children[0]) === null || _node$children$ === void 0 ? void 0 : _node$children$.type) !== "list") {
|
|
40479
|
+
prefix.push(" ");
|
|
40480
|
+
}
|
|
40481
|
+
return prefix.concat(node.children.flatMap(function(child) {
|
|
40482
|
+
if (child.type === "list") {
|
|
40483
|
+
return child.children.flatMap(function(subChild) {
|
|
40484
|
+
return formatListItemNode(getListPrefix(child), subChild, indent + 4);
|
|
40485
|
+
});
|
|
40486
|
+
} else {
|
|
40487
|
+
return [transformLeafNode(child)];
|
|
40488
|
+
}
|
|
40489
|
+
}));
|
|
40490
|
+
}
|
|
40491
|
+
function getListPrefix(node) {
|
|
40492
|
+
if (node.listType === "bullet") {
|
|
40493
|
+
return "-";
|
|
40494
|
+
} else if (node.listType === "number") {
|
|
40495
|
+
return "1.";
|
|
40496
|
+
} else {
|
|
40497
|
+
throw new Error("Unhandled list type: ".concat(node.listType));
|
|
40498
|
+
}
|
|
40499
|
+
}
|
|
40500
|
+
var FORMAT_MAPPING$1 = {
|
|
40501
|
+
bold: 1,
|
|
40502
|
+
// 0001
|
|
40503
|
+
italic: 2,
|
|
40504
|
+
// 0010
|
|
40505
|
+
"line-through": 4
|
|
40506
|
+
// 0100
|
|
40507
|
+
// underline: 8, // 1000
|
|
40508
|
+
};
|
|
40509
|
+
function fromLexicalFormat(format) {
|
|
40510
|
+
return Object.entries(FORMAT_MAPPING$1).flatMap(function(_ref) {
|
|
40511
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
40512
|
+
if ((value & /* bitwise and */
|
|
40513
|
+
format) === value) {
|
|
40514
|
+
return [key];
|
|
40515
|
+
}
|
|
40516
|
+
return [];
|
|
40517
|
+
});
|
|
40518
|
+
}
|
|
40519
|
+
var textEncoder$1 = new TextEncoder();
|
|
40520
|
+
function fromLexicalImageNode(_x2, _x3) {
|
|
40521
|
+
return _fromLexicalImageNode.apply(this, arguments);
|
|
40522
|
+
}
|
|
40523
|
+
function _fromLexicalImageNode() {
|
|
40524
|
+
_fromLexicalImageNode = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(node, files) {
|
|
40525
|
+
var _ref5, sha256, mimeType, fileExt, filePath, _ref6, _sha;
|
|
40526
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
40527
|
+
while (1)
|
|
40528
|
+
switch (_context2.prev = _context2.next) {
|
|
40529
|
+
case 0:
|
|
40530
|
+
if (!node.src.startsWith("data:")) {
|
|
40531
|
+
_context2.next = 13;
|
|
40532
|
+
break;
|
|
40533
|
+
}
|
|
40534
|
+
_context2.next = 3;
|
|
40535
|
+
return Internal.getSHA256Hash(textEncoder$1.encode(node.src));
|
|
40536
|
+
case 3:
|
|
40537
|
+
sha256 = _context2.sent;
|
|
40538
|
+
mimeType = getMimeType(node.src);
|
|
40539
|
+
if (!(mimeType === void 0)) {
|
|
40540
|
+
_context2.next = 7;
|
|
40541
|
+
break;
|
|
40542
|
+
}
|
|
40543
|
+
throw new Error("Could not detect Mime Type for image: ".concat(node.src));
|
|
40544
|
+
case 7:
|
|
40545
|
+
fileExt = mimeTypeToFileExt(mimeType);
|
|
40546
|
+
filePath = "/public/".concat(sha256, ".").concat(fileExt);
|
|
40547
|
+
files[filePath] = node.src;
|
|
40548
|
+
return _context2.abrupt("return", (_ref5 = {}, _defineProperty(_ref5, VAL_EXTENSION, "file"), _defineProperty(_ref5, FILE_REF_PROP, filePath), _defineProperty(_ref5, "metadata", {
|
|
40549
|
+
width: node.width || 0,
|
|
40550
|
+
height: node.height || 0,
|
|
40551
|
+
sha256: sha256 || ""
|
|
40552
|
+
}), _ref5));
|
|
40553
|
+
case 13:
|
|
40554
|
+
_sha = getParam("sha256", node.src);
|
|
40555
|
+
return _context2.abrupt("return", (_ref6 = {}, _defineProperty(_ref6, VAL_EXTENSION, "file"), _defineProperty(_ref6, FILE_REF_PROP, "/public".concat(node.src.split("?")[0])), _defineProperty(_ref6, "metadata", {
|
|
40556
|
+
width: node.width || 0,
|
|
40557
|
+
height: node.height || 0,
|
|
40558
|
+
sha256: _sha || ""
|
|
40559
|
+
}), _ref6));
|
|
40560
|
+
case 15:
|
|
40561
|
+
case "end":
|
|
40562
|
+
return _context2.stop();
|
|
40563
|
+
}
|
|
40564
|
+
}, _callee2);
|
|
40565
|
+
}));
|
|
40566
|
+
return _fromLexicalImageNode.apply(this, arguments);
|
|
40567
|
+
}
|
|
40568
|
+
function getParam(param, url) {
|
|
40569
|
+
var urlParts = url.split("?");
|
|
40570
|
+
if (urlParts.length < 2) {
|
|
40571
|
+
return void 0;
|
|
40572
|
+
}
|
|
40573
|
+
var queryString = urlParts[1];
|
|
40574
|
+
var params = new URLSearchParams(queryString);
|
|
40575
|
+
if (params.has(param)) {
|
|
40576
|
+
return params.get(param);
|
|
40577
|
+
}
|
|
40578
|
+
return void 0;
|
|
40579
|
+
}
|
|
40580
|
+
function fromLexicalLinkNode(node) {
|
|
40581
|
+
var _ref3;
|
|
40582
|
+
return _ref3 = {}, _defineProperty(_ref3, VAL_EXTENSION, "link"), _defineProperty(_ref3, "href", node.url), _defineProperty(_ref3, "children", node.children.map(formatText)), _ref3;
|
|
40583
|
+
}
|
|
40584
|
+
function ownKeys(e, r2) {
|
|
40585
|
+
var t = Object.keys(e);
|
|
40586
|
+
if (Object.getOwnPropertySymbols) {
|
|
40587
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
40588
|
+
r2 && (o = o.filter(function(r3) {
|
|
40589
|
+
return Object.getOwnPropertyDescriptor(e, r3).enumerable;
|
|
40590
|
+
})), t.push.apply(t, o);
|
|
40591
|
+
}
|
|
40592
|
+
return t;
|
|
40593
|
+
}
|
|
40594
|
+
function _objectSpread2(e) {
|
|
40595
|
+
for (var r2 = 1; r2 < arguments.length; r2++) {
|
|
40596
|
+
var t = null != arguments[r2] ? arguments[r2] : {};
|
|
40597
|
+
r2 % 2 ? ownKeys(Object(t), true).forEach(function(r3) {
|
|
40598
|
+
_defineProperty(e, r3, t[r3]);
|
|
40599
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r3) {
|
|
40600
|
+
Object.defineProperty(e, r3, Object.getOwnPropertyDescriptor(t, r3));
|
|
40601
|
+
});
|
|
40602
|
+
}
|
|
40603
|
+
return e;
|
|
40604
|
+
}
|
|
40605
|
+
var COMMON_LEXICAL_PROPS = {
|
|
40606
|
+
version: 1,
|
|
40607
|
+
format: "",
|
|
40608
|
+
indent: 0,
|
|
40609
|
+
direction: null
|
|
40610
|
+
};
|
|
40611
|
+
function toLexicalNode(node) {
|
|
40612
|
+
var useBreakNode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
40613
|
+
if (typeof node === "string") {
|
|
40614
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40615
|
+
type: "text",
|
|
40616
|
+
format: "",
|
|
40617
|
+
text: node
|
|
40618
|
+
});
|
|
40619
|
+
}
|
|
40620
|
+
if ("tag" in node) {
|
|
40621
|
+
switch (node.tag) {
|
|
40622
|
+
case "h1":
|
|
40623
|
+
return toLexicalHeadingNode(node);
|
|
40624
|
+
case "h2":
|
|
40625
|
+
return toLexicalHeadingNode(node);
|
|
40626
|
+
case "h3":
|
|
40627
|
+
return toLexicalHeadingNode(node);
|
|
40628
|
+
case "h4":
|
|
40629
|
+
return toLexicalHeadingNode(node);
|
|
40630
|
+
case "h5":
|
|
40631
|
+
return toLexicalHeadingNode(node);
|
|
40632
|
+
case "h6":
|
|
40633
|
+
return toLexicalHeadingNode(node);
|
|
40634
|
+
case "li":
|
|
40635
|
+
return toLexicalListItemNode(node);
|
|
40636
|
+
case "p":
|
|
40637
|
+
return toLexicalParagraphNode(node);
|
|
40638
|
+
case "ul":
|
|
40639
|
+
return toLexicalListNode(node);
|
|
40640
|
+
case "ol":
|
|
40641
|
+
return toLexicalListNode(node);
|
|
40642
|
+
case "span":
|
|
40643
|
+
return toLexicalTextNode(node);
|
|
40644
|
+
case "a":
|
|
40645
|
+
return toLexicalLinkNode(node);
|
|
40646
|
+
case "img":
|
|
40647
|
+
return toLexicalImageNode(node);
|
|
40648
|
+
case "br":
|
|
40649
|
+
if (useBreakNode) {
|
|
40650
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40651
|
+
type: "linebreak"
|
|
40652
|
+
});
|
|
40653
|
+
}
|
|
40654
|
+
return toLexicalPseudoLineBreakNode();
|
|
40655
|
+
default:
|
|
40656
|
+
throw Error("Unexpected node tag: " + JSON.stringify(node, null, 2));
|
|
40657
|
+
}
|
|
40658
|
+
} else {
|
|
40659
|
+
throw Error("Unexpected node: " + JSON.stringify(node, null, 2));
|
|
40660
|
+
}
|
|
40661
|
+
}
|
|
40662
|
+
function toLexicalImageNode(node) {
|
|
40663
|
+
var url = node.src;
|
|
40664
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40665
|
+
type: "image",
|
|
40666
|
+
src: url,
|
|
40667
|
+
width: node.width,
|
|
40668
|
+
height: node.height
|
|
40669
|
+
// TODO: altText
|
|
40670
|
+
});
|
|
40671
|
+
}
|
|
40672
|
+
function toLexicalLinkNode(link) {
|
|
40673
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40674
|
+
type: "link",
|
|
40675
|
+
url: link.href,
|
|
40676
|
+
children: link.children.map(function(child) {
|
|
40677
|
+
return toLexicalNode(child);
|
|
40678
|
+
})
|
|
40679
|
+
});
|
|
40680
|
+
}
|
|
40681
|
+
function richTextSourceToLexical(richtext) {
|
|
40682
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40683
|
+
format: "",
|
|
40684
|
+
type: "root",
|
|
40685
|
+
children: richtext.children.map(function(child) {
|
|
40686
|
+
return toLexicalNode(child);
|
|
40687
|
+
})
|
|
40688
|
+
});
|
|
40689
|
+
}
|
|
40690
|
+
function toLexicalHeadingNode(heading) {
|
|
40691
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40692
|
+
type: "heading",
|
|
40693
|
+
tag: heading.tag,
|
|
40694
|
+
children: heading.children.map(function(child) {
|
|
40695
|
+
return toLexicalNode(child);
|
|
40696
|
+
})
|
|
40697
|
+
});
|
|
40698
|
+
}
|
|
40699
|
+
function toLexicalParagraphNode(paragraph) {
|
|
40700
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40701
|
+
type: "paragraph",
|
|
40702
|
+
children: paragraph.children.map(function(child) {
|
|
40703
|
+
return toLexicalNode(child, true);
|
|
40704
|
+
})
|
|
40705
|
+
});
|
|
40706
|
+
}
|
|
40707
|
+
function toLexicalPseudoLineBreakNode() {
|
|
40708
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40709
|
+
type: "paragraph",
|
|
40710
|
+
children: []
|
|
40711
|
+
});
|
|
40712
|
+
}
|
|
40713
|
+
function toLexicalListItemNode(listItem) {
|
|
40714
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40715
|
+
type: "listitem",
|
|
40716
|
+
children: listItem.children.map(function(child) {
|
|
40717
|
+
return toLexicalNode(child, true);
|
|
40718
|
+
})
|
|
40719
|
+
});
|
|
40720
|
+
}
|
|
40721
|
+
function toLexicalListNode(list) {
|
|
40722
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40723
|
+
type: "list",
|
|
40724
|
+
listType: list.tag === "ol" ? "number" : "bullet",
|
|
40725
|
+
children: list.children.map(function(child) {
|
|
40726
|
+
return toLexicalNode(child);
|
|
40727
|
+
})
|
|
40728
|
+
}, list.dir ? {
|
|
40729
|
+
direction: list.dir
|
|
40730
|
+
} : {
|
|
40731
|
+
direction: null
|
|
40732
|
+
});
|
|
40733
|
+
}
|
|
40734
|
+
var FORMAT_MAPPING = {
|
|
40735
|
+
bold: 1,
|
|
40736
|
+
// 0001
|
|
40737
|
+
italic: 2,
|
|
40738
|
+
// 0010
|
|
40739
|
+
"line-through": 4
|
|
40740
|
+
// 0100
|
|
40741
|
+
// underline: 8, // 1000
|
|
40742
|
+
};
|
|
40743
|
+
function toLexicalFormat(classes) {
|
|
40744
|
+
return classes.reduce(function(prev, curr) {
|
|
40745
|
+
return prev | /* bitwise or */
|
|
40746
|
+
FORMAT_MAPPING[curr];
|
|
40747
|
+
}, 0);
|
|
40748
|
+
}
|
|
40749
|
+
function toLexicalTextNode(spanNode) {
|
|
40750
|
+
var child = spanNode.children[0];
|
|
40751
|
+
if (typeof child === "string") {
|
|
40752
|
+
return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
|
|
40753
|
+
type: "text",
|
|
40754
|
+
text: child,
|
|
40755
|
+
format: toLexicalFormat(spanNode.classes)
|
|
40756
|
+
});
|
|
40757
|
+
} else {
|
|
40758
|
+
return toLexicalTextNode(_objectSpread2(_objectSpread2({}, child), {}, {
|
|
40759
|
+
classes: spanNode.classes.concat(child.classes)
|
|
40760
|
+
}));
|
|
40761
|
+
}
|
|
40762
|
+
}
|
|
40763
|
+
function _typeof(o) {
|
|
40764
|
+
"@babel/helpers - typeof";
|
|
40765
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
40766
|
+
return typeof o2;
|
|
40767
|
+
} : function(o2) {
|
|
40768
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
40769
|
+
}, _typeof(o);
|
|
40770
|
+
}
|
|
40771
|
+
var VAL_START_TAG_PREFIX = '<val value="';
|
|
40772
|
+
var VAL_START_TAG_SUFFIX = '">';
|
|
40773
|
+
var VAL_END_TAG = "</val>";
|
|
40774
|
+
function parseTokens(tokens, sourceNodes, cursor) {
|
|
40775
|
+
var insideList = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
|
|
40776
|
+
var children = [];
|
|
40777
|
+
var _loop = function _loop2() {
|
|
40778
|
+
var token = tokens[cursor];
|
|
40779
|
+
if (token.type === "heading") {
|
|
40780
|
+
children.push({
|
|
40781
|
+
tag: "h".concat(token.depth),
|
|
40782
|
+
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
|
40783
|
+
});
|
|
40784
|
+
} else if (token.type === "paragraph") {
|
|
40785
|
+
children.push({
|
|
40786
|
+
tag: "p",
|
|
40787
|
+
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
|
40788
|
+
});
|
|
40789
|
+
} else if (token.type === "strong") {
|
|
40790
|
+
children.push({
|
|
40791
|
+
tag: "span",
|
|
40792
|
+
classes: ["bold"],
|
|
40793
|
+
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
|
40794
|
+
});
|
|
40795
|
+
} else if (token.type === "em") {
|
|
40796
|
+
children.push({
|
|
40797
|
+
tag: "span",
|
|
40798
|
+
classes: ["italic"],
|
|
40799
|
+
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
|
40800
|
+
});
|
|
40801
|
+
} else if (token.type === "del") {
|
|
40802
|
+
children.push({
|
|
40803
|
+
tag: "span",
|
|
40804
|
+
classes: ["line-through"],
|
|
40805
|
+
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
|
40806
|
+
});
|
|
40807
|
+
} else if (token.type === "text") {
|
|
40808
|
+
if ("tokens" in token && Array.isArray(token.tokens)) {
|
|
40809
|
+
children.push.apply(children, _toConsumableArray(parseTokens(token.tokens, sourceNodes, cursor, insideList).children));
|
|
40810
|
+
} else {
|
|
40811
|
+
if (insideList && typeof token.raw === "string") {
|
|
40812
|
+
var lines = token.raw.split("\n");
|
|
40813
|
+
var tags = lines.flatMap(function(line, i) {
|
|
40814
|
+
if (i === lines.length - 1)
|
|
40815
|
+
return [line];
|
|
40816
|
+
return [line, {
|
|
40817
|
+
tag: "br",
|
|
40818
|
+
children: []
|
|
40819
|
+
}];
|
|
40820
|
+
});
|
|
40821
|
+
children.push.apply(children, _toConsumableArray(tags));
|
|
40822
|
+
} else {
|
|
40823
|
+
children.push(token.raw);
|
|
40824
|
+
}
|
|
40825
|
+
}
|
|
40826
|
+
} else if (token.type === "list") {
|
|
40827
|
+
children.push({
|
|
40828
|
+
tag: token.ordered ? "ol" : "ul",
|
|
40829
|
+
children: parseTokens(token.items, sourceNodes, 0).children
|
|
40830
|
+
});
|
|
40831
|
+
} else if (token.type === "list_item") {
|
|
40832
|
+
children.push({
|
|
40833
|
+
tag: "li",
|
|
40834
|
+
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0, true).children
|
|
40835
|
+
});
|
|
40836
|
+
} else if (token.type === "space")
|
|
40837
|
+
;
|
|
40838
|
+
else if (token.type === "html") {
|
|
40839
|
+
if (token.text === VAL_END_TAG) {
|
|
40840
|
+
return {
|
|
40841
|
+
v: {
|
|
40842
|
+
children,
|
|
40843
|
+
cursor
|
|
40844
|
+
}
|
|
40845
|
+
};
|
|
40846
|
+
}
|
|
40847
|
+
var suffixIndex = token.text.indexOf(VAL_START_TAG_SUFFIX);
|
|
40848
|
+
if (token.text.startsWith(VAL_START_TAG_PREFIX) && suffixIndex > -1) {
|
|
40849
|
+
var number = Number(token.text.slice(VAL_START_TAG_PREFIX.length, suffixIndex));
|
|
40850
|
+
if (Number.isNaN(number)) {
|
|
40851
|
+
throw Error("Illegal val intermediate node: ".concat(JSON.stringify(token)));
|
|
40852
|
+
}
|
|
40853
|
+
var _parseTokens = parseTokens(tokens.map(function(token2) {
|
|
40854
|
+
if (token2.type === "link" || token2.type === "list") {
|
|
40855
|
+
return {
|
|
40856
|
+
type: "text",
|
|
40857
|
+
raw: token2.raw,
|
|
40858
|
+
text: token2.raw
|
|
40859
|
+
};
|
|
40860
|
+
}
|
|
40861
|
+
return token2;
|
|
40862
|
+
}), sourceNodes, cursor + 1), subChildren = _parseTokens.children, subCursor = _parseTokens.cursor;
|
|
40863
|
+
var sourceNode = sourceNodes[number];
|
|
40864
|
+
if (sourceNode._type === "link") {
|
|
40865
|
+
children.push({
|
|
40866
|
+
tag: "a",
|
|
40867
|
+
href: sourceNode.href,
|
|
40868
|
+
children: subChildren
|
|
40869
|
+
});
|
|
40870
|
+
} else if (sourceNode._type === "file") {
|
|
40871
|
+
var _sourceNode$metadata, _sourceNode$metadata2;
|
|
40872
|
+
children.push({
|
|
40873
|
+
tag: "img",
|
|
40874
|
+
src: Internal.convertFileSource(sourceNode).url,
|
|
40875
|
+
width: (_sourceNode$metadata = sourceNode.metadata) === null || _sourceNode$metadata === void 0 ? void 0 : _sourceNode$metadata.width,
|
|
40876
|
+
height: (_sourceNode$metadata2 = sourceNode.metadata) === null || _sourceNode$metadata2 === void 0 ? void 0 : _sourceNode$metadata2.height,
|
|
40877
|
+
children: []
|
|
40878
|
+
});
|
|
40879
|
+
}
|
|
40880
|
+
cursor = subCursor;
|
|
40881
|
+
}
|
|
40882
|
+
var br_html_regex = /<br\s*\/?>/gi;
|
|
40883
|
+
if (token.text.trim().match(br_html_regex)) {
|
|
40884
|
+
children.push({
|
|
40885
|
+
tag: "br",
|
|
40886
|
+
children: []
|
|
40887
|
+
});
|
|
40888
|
+
}
|
|
40889
|
+
} else if (token.type === "link") {
|
|
40890
|
+
if (token.raw === token.href) {
|
|
40891
|
+
children.push(token.raw);
|
|
40892
|
+
} else {
|
|
40893
|
+
children.push({
|
|
40894
|
+
tag: "a",
|
|
40895
|
+
href: token.href,
|
|
40896
|
+
children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
|
|
40897
|
+
});
|
|
40898
|
+
}
|
|
40899
|
+
} else if (token.type === "br") {
|
|
40900
|
+
children.push({
|
|
40901
|
+
tag: "br",
|
|
40902
|
+
children: []
|
|
40903
|
+
});
|
|
40904
|
+
} else {
|
|
40905
|
+
console.error("Could not parse markdown: unsupported token type: ".concat(token.type, ". Found: ").concat(token.raw));
|
|
40906
|
+
}
|
|
40907
|
+
cursor++;
|
|
40908
|
+
};
|
|
40909
|
+
while (cursor < tokens.length) {
|
|
40910
|
+
var _ret = _loop();
|
|
40911
|
+
if (_typeof(_ret) === "object")
|
|
40912
|
+
return _ret.v;
|
|
40913
|
+
}
|
|
40914
|
+
return {
|
|
40915
|
+
children,
|
|
40916
|
+
cursor
|
|
40917
|
+
};
|
|
40918
|
+
}
|
|
40919
|
+
function parseRichTextSource(_ref) {
|
|
40920
|
+
var _ref2;
|
|
40921
|
+
var templateStrings = _ref.templateStrings, nodes = _ref.exprs;
|
|
40922
|
+
var inputText = templateStrings.flatMap(function(templateString, i) {
|
|
40923
|
+
var node = nodes[i];
|
|
40924
|
+
if (node) {
|
|
40925
|
+
if (node[VAL_EXTENSION] === "link") {
|
|
40926
|
+
return templateString.concat("".concat(VAL_START_TAG_PREFIX).concat(i).concat(VAL_START_TAG_SUFFIX).concat(node.children[0]).concat(VAL_END_TAG));
|
|
40927
|
+
} else {
|
|
40928
|
+
return templateString.concat("".concat(VAL_START_TAG_PREFIX).concat(i).concat(VAL_START_TAG_SUFFIX).concat(VAL_END_TAG));
|
|
40929
|
+
}
|
|
40930
|
+
}
|
|
40931
|
+
return templateString;
|
|
40932
|
+
}).join("");
|
|
40933
|
+
var tokenList = lexer(inputText, {
|
|
40934
|
+
gfm: true
|
|
40935
|
+
});
|
|
40936
|
+
var _parseTokens2 = parseTokens(tokenList, nodes, 0), children = _parseTokens2.children, cursor = _parseTokens2.cursor;
|
|
40937
|
+
if (cursor !== tokenList.length) {
|
|
40938
|
+
throw Error("Unexpectedly terminated markdown parsing. Possible reason: unclosed html tag?");
|
|
39990
40939
|
}
|
|
39991
|
-
return {
|
|
39992
|
-
[VAL_EXTENSION]: "richtext",
|
|
39993
|
-
children
|
|
39994
|
-
};
|
|
40940
|
+
return _ref2 = {}, _defineProperty(_ref2, VAL_EXTENSION, "richtext"), _defineProperty(_ref2, "children", children), _ref2;
|
|
39995
40941
|
}
|
|
39996
40942
|
var LexicalList_dev = {};
|
|
39997
40943
|
var Lexical_dev = {};
|
|
@@ -61437,7 +62383,7 @@ const Dropdown = ({
|
|
|
61437
62383
|
) });
|
|
61438
62384
|
};
|
|
61439
62385
|
const Dropdown$1 = Dropdown;
|
|
61440
|
-
const textEncoder
|
|
62386
|
+
const textEncoder = new TextEncoder();
|
|
61441
62387
|
function readImage(ev) {
|
|
61442
62388
|
return new Promise((resolve, reject) => {
|
|
61443
62389
|
var _a;
|
|
@@ -61449,7 +62395,7 @@ function readImage(ev) {
|
|
|
61449
62395
|
const image = new Image();
|
|
61450
62396
|
image.addEventListener("load", async () => {
|
|
61451
62397
|
const sha256 = await Internal.getSHA256Hash(
|
|
61452
|
-
textEncoder
|
|
62398
|
+
textEncoder.encode(result2)
|
|
61453
62399
|
);
|
|
61454
62400
|
if (image.naturalWidth && image.naturalHeight) {
|
|
61455
62401
|
const mimeType = getMimeType(result2);
|
|
@@ -62986,173 +63932,6 @@ const Toolbar = ({
|
|
|
62986
63932
|
] });
|
|
62987
63933
|
};
|
|
62988
63934
|
const Toolbar$1 = Toolbar;
|
|
62989
|
-
const COMMON_LEXICAL_PROPS = {
|
|
62990
|
-
version: 1,
|
|
62991
|
-
format: "",
|
|
62992
|
-
indent: 0,
|
|
62993
|
-
direction: null
|
|
62994
|
-
};
|
|
62995
|
-
function toLexicalNode(node, useBreakNode = false) {
|
|
62996
|
-
if (typeof node === "string") {
|
|
62997
|
-
return {
|
|
62998
|
-
...COMMON_LEXICAL_PROPS,
|
|
62999
|
-
type: "text",
|
|
63000
|
-
format: "",
|
|
63001
|
-
text: node
|
|
63002
|
-
};
|
|
63003
|
-
}
|
|
63004
|
-
if ("tag" in node) {
|
|
63005
|
-
switch (node.tag) {
|
|
63006
|
-
case "h1":
|
|
63007
|
-
return toLexicalHeadingNode(node);
|
|
63008
|
-
case "h2":
|
|
63009
|
-
return toLexicalHeadingNode(node);
|
|
63010
|
-
case "h3":
|
|
63011
|
-
return toLexicalHeadingNode(node);
|
|
63012
|
-
case "h4":
|
|
63013
|
-
return toLexicalHeadingNode(node);
|
|
63014
|
-
case "h5":
|
|
63015
|
-
return toLexicalHeadingNode(node);
|
|
63016
|
-
case "h6":
|
|
63017
|
-
return toLexicalHeadingNode(node);
|
|
63018
|
-
case "li":
|
|
63019
|
-
return toLexicalListItemNode(node);
|
|
63020
|
-
case "p":
|
|
63021
|
-
return toLexicalParagraphNode(node);
|
|
63022
|
-
case "ul":
|
|
63023
|
-
return toLexicalListNode(node);
|
|
63024
|
-
case "ol":
|
|
63025
|
-
return toLexicalListNode(node);
|
|
63026
|
-
case "span":
|
|
63027
|
-
return toLexicalTextNode(node);
|
|
63028
|
-
case "a":
|
|
63029
|
-
return toLexicalLinkNode(node);
|
|
63030
|
-
case "img":
|
|
63031
|
-
return toLexicalImageNode(node);
|
|
63032
|
-
case "br":
|
|
63033
|
-
if (useBreakNode) {
|
|
63034
|
-
return {
|
|
63035
|
-
...COMMON_LEXICAL_PROPS,
|
|
63036
|
-
type: "linebreak"
|
|
63037
|
-
};
|
|
63038
|
-
}
|
|
63039
|
-
return toLexicalPseudoLineBreakNode();
|
|
63040
|
-
default:
|
|
63041
|
-
throw Error("Unexpected node tag: " + JSON.stringify(node, null, 2));
|
|
63042
|
-
}
|
|
63043
|
-
} else {
|
|
63044
|
-
throw Error("Unexpected node: " + JSON.stringify(node, null, 2));
|
|
63045
|
-
}
|
|
63046
|
-
}
|
|
63047
|
-
function toLexicalImageNode(node) {
|
|
63048
|
-
const url = node.src;
|
|
63049
|
-
return {
|
|
63050
|
-
...COMMON_LEXICAL_PROPS,
|
|
63051
|
-
type: "image",
|
|
63052
|
-
src: url,
|
|
63053
|
-
width: node.width,
|
|
63054
|
-
height: node.height
|
|
63055
|
-
// TODO: altText
|
|
63056
|
-
};
|
|
63057
|
-
}
|
|
63058
|
-
function toLexicalLinkNode(link) {
|
|
63059
|
-
return {
|
|
63060
|
-
...COMMON_LEXICAL_PROPS,
|
|
63061
|
-
type: "link",
|
|
63062
|
-
url: link.href,
|
|
63063
|
-
children: link.children.map(
|
|
63064
|
-
(child) => toLexicalNode(child)
|
|
63065
|
-
)
|
|
63066
|
-
};
|
|
63067
|
-
}
|
|
63068
|
-
function richTextSourceToLexical(richtext) {
|
|
63069
|
-
return {
|
|
63070
|
-
...COMMON_LEXICAL_PROPS,
|
|
63071
|
-
format: "",
|
|
63072
|
-
type: "root",
|
|
63073
|
-
children: richtext.children.map(
|
|
63074
|
-
(child) => toLexicalNode(child)
|
|
63075
|
-
)
|
|
63076
|
-
};
|
|
63077
|
-
}
|
|
63078
|
-
function toLexicalHeadingNode(heading) {
|
|
63079
|
-
return {
|
|
63080
|
-
...COMMON_LEXICAL_PROPS,
|
|
63081
|
-
type: "heading",
|
|
63082
|
-
tag: heading.tag,
|
|
63083
|
-
children: heading.children.map(
|
|
63084
|
-
(child) => toLexicalNode(child)
|
|
63085
|
-
)
|
|
63086
|
-
};
|
|
63087
|
-
}
|
|
63088
|
-
function toLexicalParagraphNode(paragraph) {
|
|
63089
|
-
return {
|
|
63090
|
-
...COMMON_LEXICAL_PROPS,
|
|
63091
|
-
type: "paragraph",
|
|
63092
|
-
children: paragraph.children.map(
|
|
63093
|
-
(child) => toLexicalNode(child, true)
|
|
63094
|
-
)
|
|
63095
|
-
};
|
|
63096
|
-
}
|
|
63097
|
-
function toLexicalPseudoLineBreakNode() {
|
|
63098
|
-
return {
|
|
63099
|
-
...COMMON_LEXICAL_PROPS,
|
|
63100
|
-
type: "paragraph",
|
|
63101
|
-
children: []
|
|
63102
|
-
};
|
|
63103
|
-
}
|
|
63104
|
-
function toLexicalListItemNode(listItem) {
|
|
63105
|
-
return {
|
|
63106
|
-
...COMMON_LEXICAL_PROPS,
|
|
63107
|
-
type: "listitem",
|
|
63108
|
-
children: listItem.children.map(
|
|
63109
|
-
(child) => toLexicalNode(child, true)
|
|
63110
|
-
)
|
|
63111
|
-
};
|
|
63112
|
-
}
|
|
63113
|
-
function toLexicalListNode(list) {
|
|
63114
|
-
return {
|
|
63115
|
-
...COMMON_LEXICAL_PROPS,
|
|
63116
|
-
type: "list",
|
|
63117
|
-
listType: list.tag === "ol" ? "number" : "bullet",
|
|
63118
|
-
children: list.children.map(
|
|
63119
|
-
(child) => toLexicalNode(child)
|
|
63120
|
-
),
|
|
63121
|
-
...list.dir ? { direction: list.dir } : { direction: null }
|
|
63122
|
-
};
|
|
63123
|
-
}
|
|
63124
|
-
const FORMAT_MAPPING$1 = {
|
|
63125
|
-
bold: 1,
|
|
63126
|
-
// 0001
|
|
63127
|
-
italic: 2,
|
|
63128
|
-
// 0010
|
|
63129
|
-
"line-through": 4
|
|
63130
|
-
// 0100
|
|
63131
|
-
// underline: 8, // 1000
|
|
63132
|
-
};
|
|
63133
|
-
function toLexicalFormat(classes) {
|
|
63134
|
-
return classes.reduce(
|
|
63135
|
-
(prev, curr) => prev | /* bitwise or */
|
|
63136
|
-
FORMAT_MAPPING$1[curr],
|
|
63137
|
-
0
|
|
63138
|
-
);
|
|
63139
|
-
}
|
|
63140
|
-
function toLexicalTextNode(spanNode) {
|
|
63141
|
-
const child = spanNode.children[0];
|
|
63142
|
-
if (typeof child === "string") {
|
|
63143
|
-
return {
|
|
63144
|
-
...COMMON_LEXICAL_PROPS,
|
|
63145
|
-
type: "text",
|
|
63146
|
-
text: child,
|
|
63147
|
-
format: toLexicalFormat(spanNode.classes)
|
|
63148
|
-
};
|
|
63149
|
-
} else {
|
|
63150
|
-
return toLexicalTextNode({
|
|
63151
|
-
...child,
|
|
63152
|
-
classes: spanNode.classes.concat(child.classes)
|
|
63153
|
-
});
|
|
63154
|
-
}
|
|
63155
|
-
}
|
|
63156
63935
|
function onError(error) {
|
|
63157
63936
|
console.error(error);
|
|
63158
63937
|
}
|
|
@@ -63550,210 +64329,6 @@ function useTheme(defaultTheme = "dark") {
|
|
|
63550
64329
|
}
|
|
63551
64330
|
];
|
|
63552
64331
|
}
|
|
63553
|
-
const HeaderRegEx = /^h([\d+])$/;
|
|
63554
|
-
function lexicalToRichTextSource(node) {
|
|
63555
|
-
const markdownIRBlocks = node.children.map(createBlock);
|
|
63556
|
-
return fromIRToRichTextSource(markdownIRBlocks);
|
|
63557
|
-
}
|
|
63558
|
-
function createBlock(node) {
|
|
63559
|
-
var _a;
|
|
63560
|
-
if (node.type === "heading") {
|
|
63561
|
-
let headingTag = "";
|
|
63562
|
-
const depth = Number((_a = node.tag.match(HeaderRegEx)) == null ? void 0 : _a[1]);
|
|
63563
|
-
if (Number.isNaN(depth)) {
|
|
63564
|
-
throw new Error("Invalid header depth");
|
|
63565
|
-
}
|
|
63566
|
-
for (let i = 0; i < Number(depth); i++) {
|
|
63567
|
-
headingTag += "#";
|
|
63568
|
-
}
|
|
63569
|
-
const headingText = [`${headingTag} `];
|
|
63570
|
-
return {
|
|
63571
|
-
type: "block",
|
|
63572
|
-
children: headingText.concat(...node.children.map(transformLeafNode))
|
|
63573
|
-
};
|
|
63574
|
-
} else if (node.type === "paragraph") {
|
|
63575
|
-
if (node.children.length === 0) {
|
|
63576
|
-
return {
|
|
63577
|
-
type: "block",
|
|
63578
|
-
children: ["<br />"]
|
|
63579
|
-
};
|
|
63580
|
-
}
|
|
63581
|
-
return {
|
|
63582
|
-
type: "block",
|
|
63583
|
-
children: node.children.map((child) => transformLeafNode(child))
|
|
63584
|
-
};
|
|
63585
|
-
} else if (node.type === "list") {
|
|
63586
|
-
return {
|
|
63587
|
-
type: "block",
|
|
63588
|
-
children: node.children.flatMap(
|
|
63589
|
-
(child, i) => formatListItemNode(getListPrefix(node), child, 0, i === 0)
|
|
63590
|
-
)
|
|
63591
|
-
};
|
|
63592
|
-
} else {
|
|
63593
|
-
const exhaustiveCheck = node;
|
|
63594
|
-
throw new Error(
|
|
63595
|
-
`Unhandled node type: ${"type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"}`
|
|
63596
|
-
);
|
|
63597
|
-
}
|
|
63598
|
-
}
|
|
63599
|
-
async function fromIRToRichTextSource(markdownIRBlocks) {
|
|
63600
|
-
const templateStrings = ["\n"];
|
|
63601
|
-
const exprs = [];
|
|
63602
|
-
const files = {};
|
|
63603
|
-
for (let blockIdx = 0; blockIdx < markdownIRBlocks.length; blockIdx++) {
|
|
63604
|
-
const block2 = markdownIRBlocks[blockIdx];
|
|
63605
|
-
for (const child of block2.children) {
|
|
63606
|
-
if (typeof child === "string") {
|
|
63607
|
-
templateStrings[templateStrings.length - 1] += child;
|
|
63608
|
-
} else {
|
|
63609
|
-
if (child.type === "image") {
|
|
63610
|
-
exprs.push(await fromLexicalImageNode(child, files));
|
|
63611
|
-
} else if (child.type === "link") {
|
|
63612
|
-
exprs.push(fromLexicalLinkNode(child));
|
|
63613
|
-
} else {
|
|
63614
|
-
const exhaustiveCheck = child;
|
|
63615
|
-
throw new Error(
|
|
63616
|
-
`Unexpected node type: ${JSON.stringify(exhaustiveCheck, null, 2)}`
|
|
63617
|
-
);
|
|
63618
|
-
}
|
|
63619
|
-
templateStrings.push("");
|
|
63620
|
-
}
|
|
63621
|
-
}
|
|
63622
|
-
if (blockIdx === markdownIRBlocks.length - 1) {
|
|
63623
|
-
templateStrings[templateStrings.length - 1] += "\n";
|
|
63624
|
-
} else {
|
|
63625
|
-
templateStrings[templateStrings.length - 1] += "\n\n";
|
|
63626
|
-
}
|
|
63627
|
-
}
|
|
63628
|
-
return { [VAL_EXTENSION]: "richtext", templateStrings, exprs, files };
|
|
63629
|
-
}
|
|
63630
|
-
function formatText(node) {
|
|
63631
|
-
const classes = typeof node.format === "number" ? fromLexicalFormat(node.format) : [];
|
|
63632
|
-
let text = node.text.trimStart();
|
|
63633
|
-
const prefixWS = node.text.length - text.length;
|
|
63634
|
-
text = text.trimEnd();
|
|
63635
|
-
const suffixWS = node.text.length - text.length - prefixWS;
|
|
63636
|
-
if (classes.includes("bold") && classes.includes("italic")) {
|
|
63637
|
-
text = `***${text}***`;
|
|
63638
|
-
} else if (classes.includes("bold")) {
|
|
63639
|
-
text = `**${text}**`;
|
|
63640
|
-
} else if (classes.includes("italic")) {
|
|
63641
|
-
text = `_${text}_`;
|
|
63642
|
-
}
|
|
63643
|
-
if (classes.includes("line-through")) {
|
|
63644
|
-
text = `~~${text}~~`;
|
|
63645
|
-
}
|
|
63646
|
-
return `${" ".repeat(prefixWS)}${text}${" ".repeat(suffixWS)}`;
|
|
63647
|
-
}
|
|
63648
|
-
function transformLeafNode(node) {
|
|
63649
|
-
if (node.type === "text") {
|
|
63650
|
-
return formatText(node);
|
|
63651
|
-
} else if (node.type === "linebreak") {
|
|
63652
|
-
return "\n";
|
|
63653
|
-
} else {
|
|
63654
|
-
return node;
|
|
63655
|
-
}
|
|
63656
|
-
}
|
|
63657
|
-
function formatListItemNode(listPrefix, node, indent, isFirstTopLevelListItem = false) {
|
|
63658
|
-
var _a, _b;
|
|
63659
|
-
const newLine = isFirstTopLevelListItem ? "" : "\n";
|
|
63660
|
-
const prefix = [
|
|
63661
|
-
`${newLine}${" ".repeat(indent)}${listPrefix}`
|
|
63662
|
-
];
|
|
63663
|
-
if (((_b = (_a = node.children) == null ? void 0 : _a[0]) == null ? void 0 : _b.type) !== "list") {
|
|
63664
|
-
prefix.push(" ");
|
|
63665
|
-
}
|
|
63666
|
-
return prefix.concat(
|
|
63667
|
-
node.children.flatMap((child) => {
|
|
63668
|
-
if (child.type === "list") {
|
|
63669
|
-
return child.children.flatMap(
|
|
63670
|
-
(subChild) => formatListItemNode(getListPrefix(child), subChild, indent + 4)
|
|
63671
|
-
);
|
|
63672
|
-
} else {
|
|
63673
|
-
return [transformLeafNode(child)];
|
|
63674
|
-
}
|
|
63675
|
-
})
|
|
63676
|
-
);
|
|
63677
|
-
}
|
|
63678
|
-
function getListPrefix(node) {
|
|
63679
|
-
if (node.listType === "bullet") {
|
|
63680
|
-
return "-";
|
|
63681
|
-
} else if (node.listType === "number") {
|
|
63682
|
-
return "1.";
|
|
63683
|
-
} else {
|
|
63684
|
-
throw new Error(`Unhandled list type: ${node.listType}`);
|
|
63685
|
-
}
|
|
63686
|
-
}
|
|
63687
|
-
const FORMAT_MAPPING = {
|
|
63688
|
-
bold: 1,
|
|
63689
|
-
// 0001
|
|
63690
|
-
italic: 2,
|
|
63691
|
-
// 0010
|
|
63692
|
-
"line-through": 4
|
|
63693
|
-
// 0100
|
|
63694
|
-
// underline: 8, // 1000
|
|
63695
|
-
};
|
|
63696
|
-
function fromLexicalFormat(format) {
|
|
63697
|
-
return Object.entries(FORMAT_MAPPING).flatMap(([key, value]) => {
|
|
63698
|
-
if ((value & /* bitwise and */
|
|
63699
|
-
format) === value) {
|
|
63700
|
-
return [key];
|
|
63701
|
-
}
|
|
63702
|
-
return [];
|
|
63703
|
-
});
|
|
63704
|
-
}
|
|
63705
|
-
const textEncoder = new TextEncoder();
|
|
63706
|
-
async function fromLexicalImageNode(node, files) {
|
|
63707
|
-
if (node.src.startsWith("data:")) {
|
|
63708
|
-
const sha256 = await Internal.getSHA256Hash(textEncoder.encode(node.src));
|
|
63709
|
-
const mimeType = getMimeType(node.src);
|
|
63710
|
-
if (mimeType === void 0) {
|
|
63711
|
-
throw new Error(`Could not detect Mime Type for image: ${node.src}`);
|
|
63712
|
-
}
|
|
63713
|
-
const fileExt = mimeTypeToFileExt(mimeType);
|
|
63714
|
-
const filePath = `/public/${sha256}.${fileExt}`;
|
|
63715
|
-
files[filePath] = node.src;
|
|
63716
|
-
return {
|
|
63717
|
-
[VAL_EXTENSION]: "file",
|
|
63718
|
-
[FILE_REF_PROP]: filePath,
|
|
63719
|
-
metadata: {
|
|
63720
|
-
width: node.width || 0,
|
|
63721
|
-
height: node.height || 0,
|
|
63722
|
-
sha256: sha256 || ""
|
|
63723
|
-
}
|
|
63724
|
-
};
|
|
63725
|
-
} else {
|
|
63726
|
-
const sha256 = getParam("sha256", node.src);
|
|
63727
|
-
return {
|
|
63728
|
-
[VAL_EXTENSION]: "file",
|
|
63729
|
-
[FILE_REF_PROP]: `/public${node.src.split("?")[0]}`,
|
|
63730
|
-
metadata: {
|
|
63731
|
-
width: node.width || 0,
|
|
63732
|
-
height: node.height || 0,
|
|
63733
|
-
sha256: sha256 || ""
|
|
63734
|
-
}
|
|
63735
|
-
};
|
|
63736
|
-
}
|
|
63737
|
-
}
|
|
63738
|
-
function getParam(param, url) {
|
|
63739
|
-
const urlParts = url.split("?");
|
|
63740
|
-
if (urlParts.length < 2) {
|
|
63741
|
-
return void 0;
|
|
63742
|
-
}
|
|
63743
|
-
const queryString = urlParts[1];
|
|
63744
|
-
const params = new URLSearchParams(queryString);
|
|
63745
|
-
if (params.has(param)) {
|
|
63746
|
-
return params.get(param);
|
|
63747
|
-
}
|
|
63748
|
-
return void 0;
|
|
63749
|
-
}
|
|
63750
|
-
function fromLexicalLinkNode(node) {
|
|
63751
|
-
return {
|
|
63752
|
-
[VAL_EXTENSION]: "link",
|
|
63753
|
-
href: node.url,
|
|
63754
|
-
children: node.children.map(formatText)
|
|
63755
|
-
};
|
|
63756
|
-
}
|
|
63757
64332
|
const Input = reactExports.forwardRef(
|
|
63758
64333
|
({ className: className2, type, ...props }, ref) => {
|
|
63759
64334
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|