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