@valbuild/shared 0.43.1 → 0.44.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.
@@ -25,306 +25,36 @@ function _interopNamespace(e) {
25
25
 
26
26
  var marked__namespace = /*#__PURE__*/_interopNamespace(marked);
27
27
 
28
- function _regeneratorRuntime() {
29
- _regeneratorRuntime = function () {
30
- return e;
31
- };
32
- var t,
33
- e = {},
34
- r = Object.prototype,
35
- n = r.hasOwnProperty,
36
- o = Object.defineProperty || function (t, e, r) {
37
- t[e] = r.value;
38
- },
39
- i = "function" == typeof Symbol ? Symbol : {},
40
- a = i.iterator || "@@iterator",
41
- c = i.asyncIterator || "@@asyncIterator",
42
- u = i.toStringTag || "@@toStringTag";
43
- function define(t, e, r) {
44
- return Object.defineProperty(t, e, {
45
- value: r,
46
- enumerable: !0,
47
- configurable: !0,
48
- writable: !0
49
- }), t[e];
50
- }
51
- try {
52
- define({}, "");
53
- } catch (t) {
54
- define = function (t, e, r) {
55
- return t[e] = r;
56
- };
57
- }
58
- function wrap(t, e, r, n) {
59
- var i = e && e.prototype instanceof Generator ? e : Generator,
60
- a = Object.create(i.prototype),
61
- c = new Context(n || []);
62
- return o(a, "_invoke", {
63
- value: makeInvokeMethod(t, r, c)
64
- }), a;
65
- }
66
- function tryCatch(t, e, r) {
28
+ function _arrayWithHoles(arr) {
29
+ if (Array.isArray(arr)) return arr;
30
+ }
31
+
32
+ function _iterableToArrayLimit(r, l) {
33
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
34
+ if (null != t) {
35
+ var e,
36
+ n,
37
+ i,
38
+ u,
39
+ a = [],
40
+ f = !0,
41
+ o = !1;
67
42
  try {
68
- return {
69
- type: "normal",
70
- arg: t.call(e, r)
71
- };
72
- } catch (t) {
73
- return {
74
- type: "throw",
75
- arg: t
76
- };
77
- }
78
- }
79
- e.wrap = wrap;
80
- var h = "suspendedStart",
81
- l = "suspendedYield",
82
- f = "executing",
83
- s = "completed",
84
- y = {};
85
- function Generator() {}
86
- function GeneratorFunction() {}
87
- function GeneratorFunctionPrototype() {}
88
- var p = {};
89
- define(p, a, function () {
90
- return this;
91
- });
92
- var d = Object.getPrototypeOf,
93
- v = d && d(d(values([])));
94
- v && v !== r && n.call(v, a) && (p = v);
95
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
96
- function defineIteratorMethods(t) {
97
- ["next", "throw", "return"].forEach(function (e) {
98
- define(t, e, function (t) {
99
- return this._invoke(e, t);
100
- });
101
- });
102
- }
103
- function AsyncIterator(t, e) {
104
- function invoke(r, o, i, a) {
105
- var c = tryCatch(t[r], t, o);
106
- if ("throw" !== c.type) {
107
- var u = c.arg,
108
- h = u.value;
109
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
110
- invoke("next", t, i, a);
111
- }, function (t) {
112
- invoke("throw", t, i, a);
113
- }) : e.resolve(h).then(function (t) {
114
- u.value = t, i(u);
115
- }, function (t) {
116
- return invoke("throw", t, i, a);
117
- });
118
- }
119
- a(c.arg);
120
- }
121
- var r;
122
- o(this, "_invoke", {
123
- value: function (t, n) {
124
- function callInvokeWithMethodAndArg() {
125
- return new e(function (e, r) {
126
- invoke(t, n, e, r);
127
- });
128
- }
129
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
130
- }
131
- });
132
- }
133
- function makeInvokeMethod(e, r, n) {
134
- var o = h;
135
- return function (i, a) {
136
- if (o === f) throw new Error("Generator is already running");
137
- if (o === s) {
138
- if ("throw" === i) throw a;
139
- return {
140
- value: t,
141
- done: !0
142
- };
143
- }
144
- for (n.method = i, n.arg = a;;) {
145
- var c = n.delegate;
146
- if (c) {
147
- var u = maybeInvokeDelegate(c, n);
148
- if (u) {
149
- if (u === y) continue;
150
- return u;
151
- }
152
- }
153
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
154
- if (o === h) throw o = s, n.arg;
155
- n.dispatchException(n.arg);
156
- } else "return" === n.method && n.abrupt("return", n.arg);
157
- o = f;
158
- var p = tryCatch(e, r, n);
159
- if ("normal" === p.type) {
160
- if (o = n.done ? s : l, p.arg === y) continue;
161
- return {
162
- value: p.arg,
163
- done: n.done
164
- };
165
- }
166
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
167
- }
168
- };
169
- }
170
- function maybeInvokeDelegate(e, r) {
171
- var n = r.method,
172
- o = e.iterator[n];
173
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
174
- var i = tryCatch(o, e.iterator, r.arg);
175
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
176
- var a = i.arg;
177
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
178
- }
179
- function pushTryEntry(t) {
180
- var e = {
181
- tryLoc: t[0]
182
- };
183
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
184
- }
185
- function resetTryEntry(t) {
186
- var e = t.completion || {};
187
- e.type = "normal", delete e.arg, t.completion = e;
188
- }
189
- function Context(t) {
190
- this.tryEntries = [{
191
- tryLoc: "root"
192
- }], t.forEach(pushTryEntry, this), this.reset(!0);
193
- }
194
- function values(e) {
195
- if (e || "" === e) {
196
- var r = e[a];
197
- if (r) return r.call(e);
198
- if ("function" == typeof e.next) return e;
199
- if (!isNaN(e.length)) {
200
- var o = -1,
201
- i = function next() {
202
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
203
- return next.value = t, next.done = !0, next;
204
- };
205
- return i.next = i;
43
+ if (i = (t = t.call(r)).next, 0 === l) {
44
+ if (Object(t) !== t) return;
45
+ f = !1;
46
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
47
+ } catch (r) {
48
+ o = !0, n = r;
49
+ } finally {
50
+ try {
51
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
52
+ } finally {
53
+ if (o) throw n;
206
54
  }
207
55
  }
208
- throw new TypeError(typeof e + " is not iterable");
56
+ return a;
209
57
  }
210
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
211
- value: GeneratorFunctionPrototype,
212
- configurable: !0
213
- }), o(GeneratorFunctionPrototype, "constructor", {
214
- value: GeneratorFunction,
215
- configurable: !0
216
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
217
- var e = "function" == typeof t && t.constructor;
218
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
219
- }, e.mark = function (t) {
220
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
221
- }, e.awrap = function (t) {
222
- return {
223
- __await: t
224
- };
225
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
226
- return this;
227
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
228
- void 0 === i && (i = Promise);
229
- var a = new AsyncIterator(wrap(t, r, n, o), i);
230
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
231
- return t.done ? t.value : a.next();
232
- });
233
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
234
- return this;
235
- }), define(g, "toString", function () {
236
- return "[object Generator]";
237
- }), e.keys = function (t) {
238
- var e = Object(t),
239
- r = [];
240
- for (var n in e) r.push(n);
241
- return r.reverse(), function next() {
242
- for (; r.length;) {
243
- var t = r.pop();
244
- if (t in e) return next.value = t, next.done = !1, next;
245
- }
246
- return next.done = !0, next;
247
- };
248
- }, e.values = values, Context.prototype = {
249
- constructor: Context,
250
- reset: function (e) {
251
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
252
- },
253
- stop: function () {
254
- this.done = !0;
255
- var t = this.tryEntries[0].completion;
256
- if ("throw" === t.type) throw t.arg;
257
- return this.rval;
258
- },
259
- dispatchException: function (e) {
260
- if (this.done) throw e;
261
- var r = this;
262
- function handle(n, o) {
263
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
264
- }
265
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
266
- var i = this.tryEntries[o],
267
- a = i.completion;
268
- if ("root" === i.tryLoc) return handle("end");
269
- if (i.tryLoc <= this.prev) {
270
- var c = n.call(i, "catchLoc"),
271
- u = n.call(i, "finallyLoc");
272
- if (c && u) {
273
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
274
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
275
- } else if (c) {
276
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
277
- } else {
278
- if (!u) throw new Error("try statement without catch or finally");
279
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
280
- }
281
- }
282
- }
283
- },
284
- abrupt: function (t, e) {
285
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
286
- var o = this.tryEntries[r];
287
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
288
- var i = o;
289
- break;
290
- }
291
- }
292
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
293
- var a = i ? i.completion : {};
294
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
295
- },
296
- complete: function (t, e) {
297
- if ("throw" === t.type) throw t.arg;
298
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
299
- },
300
- finish: function (t) {
301
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
302
- var r = this.tryEntries[e];
303
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
304
- }
305
- },
306
- catch: function (t) {
307
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
308
- var r = this.tryEntries[e];
309
- if (r.tryLoc === t) {
310
- var n = r.completion;
311
- if ("throw" === n.type) {
312
- var o = n.arg;
313
- resetTryEntry(r);
314
- }
315
- return o;
316
- }
317
- }
318
- throw new Error("illegal catch attempt");
319
- },
320
- delegateYield: function (e, r, n) {
321
- return this.delegate = {
322
- iterator: values(e),
323
- resultName: r,
324
- nextLoc: n
325
- }, "next" === this.method && (this.arg = t), y;
326
- }
327
- }, e;
328
58
  }
329
59
 
330
60
  function _arrayLikeToArray(arr, len) {
@@ -342,6 +72,45 @@ function _unsupportedIterableToArray(o, minLen) {
342
72
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
343
73
  }
344
74
 
75
+ function _nonIterableRest() {
76
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
77
+ }
78
+
79
+ function _slicedToArray(arr, i) {
80
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
81
+ }
82
+
83
+ function _toPrimitive(input, hint) {
84
+ if (typeof input !== "object" || input === null) return input;
85
+ var prim = input[Symbol.toPrimitive];
86
+ if (prim !== undefined) {
87
+ var res = prim.call(input, hint || "default");
88
+ if (typeof res !== "object") return res;
89
+ throw new TypeError("@@toPrimitive must return a primitive value.");
90
+ }
91
+ return (hint === "string" ? String : Number)(input);
92
+ }
93
+
94
+ function _toPropertyKey(arg) {
95
+ var key = _toPrimitive(arg, "string");
96
+ return typeof key === "symbol" ? key : String(key);
97
+ }
98
+
99
+ function _defineProperty(obj, key, value) {
100
+ key = _toPropertyKey(key);
101
+ if (key in obj) {
102
+ Object.defineProperty(obj, key, {
103
+ value: value,
104
+ enumerable: true,
105
+ configurable: true,
106
+ writable: true
107
+ });
108
+ } else {
109
+ obj[key] = value;
110
+ }
111
+ return obj;
112
+ }
113
+
345
114
  function _createForOfIteratorHelper(o, allowArrayLike) {
346
115
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
347
116
  if (!it) {
@@ -394,108 +163,6 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
394
163
  };
395
164
  }
396
165
 
397
- function _toPrimitive(input, hint) {
398
- if (typeof input !== "object" || input === null) return input;
399
- var prim = input[Symbol.toPrimitive];
400
- if (prim !== undefined) {
401
- var res = prim.call(input, hint || "default");
402
- if (typeof res !== "object") return res;
403
- throw new TypeError("@@toPrimitive must return a primitive value.");
404
- }
405
- return (hint === "string" ? String : Number)(input);
406
- }
407
-
408
- function _toPropertyKey(arg) {
409
- var key = _toPrimitive(arg, "string");
410
- return typeof key === "symbol" ? key : String(key);
411
- }
412
-
413
- function _defineProperty(obj, key, value) {
414
- key = _toPropertyKey(key);
415
- if (key in obj) {
416
- Object.defineProperty(obj, key, {
417
- value: value,
418
- enumerable: true,
419
- configurable: true,
420
- writable: true
421
- });
422
- } else {
423
- obj[key] = value;
424
- }
425
- return obj;
426
- }
427
-
428
- function _arrayWithHoles(arr) {
429
- if (Array.isArray(arr)) return arr;
430
- }
431
-
432
- function _iterableToArrayLimit(r, l) {
433
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
434
- if (null != t) {
435
- var e,
436
- n,
437
- i,
438
- u,
439
- a = [],
440
- f = !0,
441
- o = !1;
442
- try {
443
- if (i = (t = t.call(r)).next, 0 === l) {
444
- if (Object(t) !== t) return;
445
- f = !1;
446
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
447
- } catch (r) {
448
- o = !0, n = r;
449
- } finally {
450
- try {
451
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
452
- } finally {
453
- if (o) throw n;
454
- }
455
- }
456
- return a;
457
- }
458
- }
459
-
460
- function _nonIterableRest() {
461
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
462
- }
463
-
464
- function _slicedToArray(arr, i) {
465
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
466
- }
467
-
468
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
469
- try {
470
- var info = gen[key](arg);
471
- var value = info.value;
472
- } catch (error) {
473
- reject(error);
474
- return;
475
- }
476
- if (info.done) {
477
- resolve(value);
478
- } else {
479
- Promise.resolve(value).then(_next, _throw);
480
- }
481
- }
482
- function _asyncToGenerator(fn) {
483
- return function () {
484
- var self = this,
485
- args = arguments;
486
- return new Promise(function (resolve, reject) {
487
- var gen = fn.apply(self, args);
488
- function _next(value) {
489
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
490
- }
491
- function _throw(err) {
492
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
493
- }
494
- _next(undefined);
495
- });
496
- };
497
- }
498
-
499
166
  function _arrayWithoutHoles(arr) {
500
167
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
501
168
  }
@@ -532,6 +199,19 @@ function mimeTypeToFileExt(mimeType) {
532
199
  }
533
200
  return mimeType;
534
201
  }
202
+ function filenameToMimeType(filename) {
203
+ var ext = filename.split(".").pop();
204
+ return ext && imageTypeToMimeType(ext);
205
+ }
206
+ function imageTypeToMimeType(imageType) {
207
+ if (imageType === "svg") {
208
+ return "image/svg+xml";
209
+ }
210
+ if (imageType === "ico") {
211
+ return "image/vnd.microsoft.icon";
212
+ }
213
+ return "image/".concat(imageType);
214
+ }
535
215
 
536
216
  var HeaderRegEx = /^h([\d+])$/;
537
217
  function lexicalToRichTextSource(node) {
@@ -579,100 +259,43 @@ function createBlock(node) {
579
259
  throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
580
260
  }
581
261
  }
582
- function fromIRToRichTextSource(_x) {
583
- return _fromIRToRichTextSource.apply(this, arguments);
584
- }
585
- function _fromIRToRichTextSource() {
586
- _fromIRToRichTextSource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(markdownIRBlocks) {
587
- var templateStrings, exprs, files, blockIdx, block, _iterator, _step, child, exhaustiveCheck;
588
- return _regeneratorRuntime().wrap(function _callee$(_context) {
589
- while (1) switch (_context.prev = _context.next) {
590
- case 0:
591
- templateStrings = ["\n"];
592
- exprs = [];
593
- files = {};
594
- blockIdx = 0;
595
- case 4:
596
- if (!(blockIdx < markdownIRBlocks.length)) {
597
- _context.next = 44;
598
- break;
599
- }
600
- block = markdownIRBlocks[blockIdx];
601
- _iterator = _createForOfIteratorHelper(block.children);
602
- _context.prev = 7;
603
- _iterator.s();
604
- case 9:
605
- if ((_step = _iterator.n()).done) {
606
- _context.next = 32;
607
- break;
608
- }
609
- child = _step.value;
610
- if (!(typeof child === "string")) {
611
- _context.next = 15;
612
- break;
613
- }
262
+ function fromIRToRichTextSource(markdownIRBlocks) {
263
+ var templateStrings = ["\n"];
264
+ var exprs = [];
265
+ var files = {};
266
+ for (var blockIdx = 0; blockIdx < markdownIRBlocks.length; blockIdx++) {
267
+ var block = markdownIRBlocks[blockIdx];
268
+ var _iterator = _createForOfIteratorHelper(block.children),
269
+ _step;
270
+ try {
271
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
272
+ var child = _step.value;
273
+ if (typeof child === "string") {
614
274
  templateStrings[templateStrings.length - 1] += child;
615
- _context.next = 30;
616
- break;
617
- case 15:
618
- if (!(child.type === "image")) {
619
- _context.next = 23;
620
- break;
621
- }
622
- _context.t0 = exprs;
623
- _context.next = 19;
624
- return fromLexicalImageNode(child, files);
625
- case 19:
626
- _context.t1 = _context.sent;
627
- _context.t0.push.call(_context.t0, _context.t1);
628
- _context.next = 29;
629
- break;
630
- case 23:
631
- if (!(child.type === "link")) {
632
- _context.next = 27;
633
- break;
634
- }
635
- exprs.push(fromLexicalLinkNode(child));
636
- _context.next = 29;
637
- break;
638
- case 27:
639
- exhaustiveCheck = child;
640
- throw new Error("Unexpected node type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
641
- case 29:
642
- templateStrings.push("");
643
- case 30:
644
- _context.next = 9;
645
- break;
646
- case 32:
647
- _context.next = 37;
648
- break;
649
- case 34:
650
- _context.prev = 34;
651
- _context.t2 = _context["catch"](7);
652
- _iterator.e(_context.t2);
653
- case 37:
654
- _context.prev = 37;
655
- _iterator.f();
656
- return _context.finish(37);
657
- case 40:
658
- if (blockIdx === markdownIRBlocks.length - 1) {
659
- templateStrings[templateStrings.length - 1] += "\n";
275
+ } else {
276
+ if (child.type === "image") {
277
+ exprs.push(fromLexicalImageNode(child, files));
278
+ } else if (child.type === "link") {
279
+ exprs.push(fromLexicalLinkNode(child));
660
280
  } else {
661
- templateStrings[templateStrings.length - 1] += "\n\n";
281
+ var exhaustiveCheck = child;
282
+ throw new Error("Unexpected node type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
662
283
  }
663
- case 41:
664
- blockIdx++;
665
- _context.next = 4;
666
- break;
667
- case 44:
668
- return _context.abrupt("return", _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "richtext"), "templateStrings", templateStrings), "exprs", exprs), "files", files));
669
- case 45:
670
- case "end":
671
- return _context.stop();
284
+ templateStrings.push("");
285
+ }
672
286
  }
673
- }, _callee, null, [[7, 34, 37, 40]]);
674
- }));
675
- return _fromIRToRichTextSource.apply(this, arguments);
287
+ } catch (err) {
288
+ _iterator.e(err);
289
+ } finally {
290
+ _iterator.f();
291
+ }
292
+ if (blockIdx === markdownIRBlocks.length - 1) {
293
+ templateStrings[templateStrings.length - 1] += "\n";
294
+ } else {
295
+ templateStrings[templateStrings.length - 1] += "\n\n";
296
+ }
297
+ }
298
+ return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "richtext"), "templateStrings", templateStrings), "exprs", exprs), "files", files);
676
299
  }
677
300
  function formatText(node) {
678
301
  var classes = typeof node.format === "number" ? fromLexicalFormat(node.format) : [];
@@ -740,10 +363,10 @@ var FORMAT_MAPPING$1 = {
740
363
  };
741
364
 
742
365
  function fromLexicalFormat(format) {
743
- return Object.entries(FORMAT_MAPPING$1).flatMap(function (_ref) {
744
- var _ref2 = _slicedToArray(_ref, 2),
745
- key = _ref2[0],
746
- value = _ref2[1];
366
+ return Object.entries(FORMAT_MAPPING$1).flatMap(function (_ref2) {
367
+ var _ref3 = _slicedToArray(_ref2, 2),
368
+ key = _ref3[0],
369
+ value = _ref3[1];
747
370
  if ((value & /* bitwise and */format) === value) {
748
371
  return [key];
749
372
  }
@@ -751,52 +374,29 @@ function fromLexicalFormat(format) {
751
374
  });
752
375
  }
753
376
  var textEncoder = new TextEncoder();
754
- function fromLexicalImageNode(_x2, _x3) {
755
- return _fromLexicalImageNode.apply(this, arguments);
756
- }
757
- function _fromLexicalImageNode() {
758
- _fromLexicalImageNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(node, files) {
759
- var sha256, mimeType, fileExt, filePath, _sha;
760
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
761
- while (1) switch (_context2.prev = _context2.next) {
762
- case 0:
763
- if (!node.src.startsWith("data:")) {
764
- _context2.next = 13;
765
- break;
766
- }
767
- _context2.next = 3;
768
- return core.Internal.getSHA256Hash(textEncoder.encode(node.src));
769
- case 3:
770
- sha256 = _context2.sent;
771
- mimeType = getMimeType(node.src);
772
- if (!(mimeType === undefined)) {
773
- _context2.next = 7;
774
- break;
775
- }
776
- throw new Error("Could not detect Mime Type for image: ".concat(node.src));
777
- case 7:
778
- fileExt = mimeTypeToFileExt(mimeType);
779
- filePath = "/public/".concat(sha256, ".").concat(fileExt);
780
- files[filePath] = node.src;
781
- return _context2.abrupt("return", _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), "metadata", {
782
- width: node.width || 0,
783
- height: node.height || 0,
784
- sha256: sha256 || ""
785
- }));
786
- case 13:
787
- _sha = getParam("sha256", node.src);
788
- return _context2.abrupt("return", _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, "/public".concat(node.src.split("?")[0])), "metadata", {
789
- width: node.width || 0,
790
- height: node.height || 0,
791
- sha256: _sha || ""
792
- }));
793
- case 15:
794
- case "end":
795
- return _context2.stop();
796
- }
797
- }, _callee2);
798
- }));
799
- return _fromLexicalImageNode.apply(this, arguments);
377
+ function fromLexicalImageNode(node, files) {
378
+ if (node.src.startsWith("data:")) {
379
+ var sha256 = core.Internal.getSHA256Hash(textEncoder.encode(node.src));
380
+ var mimeType = getMimeType(node.src);
381
+ if (mimeType === undefined) {
382
+ throw new Error("Could not detect Mime Type for image: ".concat(node.src));
383
+ }
384
+ var fileExt = mimeTypeToFileExt(mimeType);
385
+ var filePath = "/public/".concat(sha256, ".").concat(fileExt);
386
+ files[filePath] = node.src;
387
+ return _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), "metadata", {
388
+ width: node.width || 0,
389
+ height: node.height || 0,
390
+ sha256: sha256 || ""
391
+ });
392
+ } else {
393
+ var _sha = getParam("sha256", node.src);
394
+ return _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, "/public".concat(node.src.split("?")[0])), "metadata", {
395
+ width: node.width || 0,
396
+ height: node.height || 0,
397
+ sha256: _sha || ""
398
+ });
399
+ }
800
400
  }
801
401
  function getParam(param, url) {
802
402
  var urlParts = url.split("?");
@@ -1183,8 +783,10 @@ exports.COMMON_LEXICAL_PROPS = COMMON_LEXICAL_PROPS;
1183
783
  exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
1184
784
  exports.VAL_SESSION_COOKIE = VAL_SESSION_COOKIE;
1185
785
  exports.VAL_STATE_COOKIE = VAL_STATE_COOKIE;
786
+ exports.filenameToMimeType = filenameToMimeType;
1186
787
  exports.fromLexicalFormat = fromLexicalFormat;
1187
788
  exports.getMimeType = getMimeType;
789
+ exports.imageTypeToMimeType = imageTypeToMimeType;
1188
790
  exports.lexicalToRichTextSource = lexicalToRichTextSource;
1189
791
  exports.mimeTypeToFileExt = mimeTypeToFileExt;
1190
792
  exports.parseRichTextSource = parseRichTextSource;