@valbuild/shared 0.48.1 → 0.50.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.
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@valbuild/core');
6
6
  var marked = require('marked');
7
+ var zod = require('zod');
7
8
 
8
9
  function _interopNamespace(e) {
9
10
  if (e && e.__esModule) return e;
@@ -25,79 +26,24 @@ function _interopNamespace(e) {
25
26
 
26
27
  var marked__namespace = /*#__PURE__*/_interopNamespace(marked);
27
28
 
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;
42
- try {
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;
54
- }
55
- }
56
- return a;
57
- }
58
- }
59
-
60
- function _arrayLikeToArray(arr, len) {
61
- if (len == null || len > arr.length) len = arr.length;
62
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
63
- return arr2;
64
- }
65
-
66
- function _unsupportedIterableToArray(o, minLen) {
67
- if (!o) return;
68
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
69
- var n = Object.prototype.toString.call(o).slice(8, -1);
70
- if (n === "Object" && o.constructor) n = o.constructor.name;
71
- if (n === "Map" || n === "Set") return Array.from(o);
72
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
73
- }
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;
29
+ function toPrimitive(t, r) {
30
+ if ("object" != typeof t || !t) return t;
31
+ var e = t[Symbol.toPrimitive];
32
+ if (void 0 !== e) {
33
+ var i = e.call(t, r || "default");
34
+ if ("object" != typeof i) return i;
89
35
  throw new TypeError("@@toPrimitive must return a primitive value.");
90
36
  }
91
- return (hint === "string" ? String : Number)(input);
37
+ return ("string" === r ? String : Number)(t);
92
38
  }
93
39
 
94
- function _toPropertyKey(arg) {
95
- var key = _toPrimitive(arg, "string");
96
- return typeof key === "symbol" ? key : String(key);
40
+ function toPropertyKey(t) {
41
+ var i = toPrimitive(t, "string");
42
+ return "symbol" == typeof i ? i : String(i);
97
43
  }
98
44
 
99
45
  function _defineProperty(obj, key, value) {
100
- key = _toPropertyKey(key);
46
+ key = toPropertyKey(key);
101
47
  if (key in obj) {
102
48
  Object.defineProperty(obj, key, {
103
49
  value: value,
@@ -111,6 +57,21 @@ function _defineProperty(obj, key, value) {
111
57
  return obj;
112
58
  }
113
59
 
60
+ function _arrayLikeToArray(arr, len) {
61
+ if (len == null || len > arr.length) len = arr.length;
62
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
63
+ return arr2;
64
+ }
65
+
66
+ function _unsupportedIterableToArray(o, minLen) {
67
+ if (!o) return;
68
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
69
+ var n = Object.prototype.toString.call(o).slice(8, -1);
70
+ if (n === "Object" && o.constructor) n = o.constructor.name;
71
+ if (n === "Map" || n === "Set") return Array.from(o);
72
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
73
+ }
74
+
114
75
  function _createForOfIteratorHelper(o, allowArrayLike) {
115
76
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
116
77
  if (!it) {
@@ -179,7 +140,746 @@ function _toConsumableArray(arr) {
179
140
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
180
141
  }
181
142
 
182
- var MIME_TYPE_REGEX = /^data:(image\/(png|jpeg|jpg|gif|webp|bmp|tiff|ico|svg\+xml));base64,/;
143
+ function _arrayWithHoles(arr) {
144
+ if (Array.isArray(arr)) return arr;
145
+ }
146
+
147
+ function _iterableToArrayLimit(r, l) {
148
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
149
+ if (null != t) {
150
+ var e,
151
+ n,
152
+ i,
153
+ u,
154
+ a = [],
155
+ f = !0,
156
+ o = !1;
157
+ try {
158
+ if (i = (t = t.call(r)).next, 0 === l) {
159
+ if (Object(t) !== t) return;
160
+ f = !1;
161
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
162
+ } catch (r) {
163
+ o = !0, n = r;
164
+ } finally {
165
+ try {
166
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
167
+ } finally {
168
+ if (o) throw n;
169
+ }
170
+ }
171
+ return a;
172
+ }
173
+ }
174
+
175
+ function _nonIterableRest() {
176
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
177
+ }
178
+
179
+ function _slicedToArray(arr, i) {
180
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
181
+ }
182
+
183
+ var EXT_TO_MIME_TYPES = {
184
+ x3d: "application/vnd.hzn-3d-crossword",
185
+ "3gp": "video/3gpp",
186
+ "3g2": "video/3gpp2",
187
+ mseq: "application/vnd.mseq",
188
+ pwn: "application/vnd.3m.post-it-notes",
189
+ plb: "application/vnd.3gpp.pic-bw-large",
190
+ psb: "application/vnd.3gpp.pic-bw-small",
191
+ pvb: "application/vnd.3gpp.pic-bw-var",
192
+ tcap: "application/vnd.3gpp2.tcap",
193
+ "7z": "application/x-7z-compressed",
194
+ abw: "application/x-abiword",
195
+ ace: "application/x-ace-compressed",
196
+ acc: "application/vnd.americandynamics.acc",
197
+ acu: "application/vnd.acucobol",
198
+ atc: "application/vnd.acucorp",
199
+ adp: "audio/adpcm",
200
+ aab: "application/x-authorware-bin",
201
+ aam: "application/x-authorware-map",
202
+ aas: "application/x-authorware-seg",
203
+ air: "application/vnd.adobe.air-application-installer-package+zip",
204
+ swf: "application/x-shockwave-flash",
205
+ fxp: "application/vnd.adobe.fxp",
206
+ pdf: "application/pdf",
207
+ ppd: "application/vnd.cups-ppd",
208
+ dir: "application/x-director",
209
+ xdp: "application/vnd.adobe.xdp+xml",
210
+ xfdf: "application/vnd.adobe.xfdf",
211
+ aac: "audio/x-aac",
212
+ ahead: "application/vnd.ahead.space",
213
+ azf: "application/vnd.airzip.filesecure.azf",
214
+ azs: "application/vnd.airzip.filesecure.azs",
215
+ azw: "application/vnd.amazon.ebook",
216
+ ami: "application/vnd.amiga.ami",
217
+ "N/A": "application/andrew-inset",
218
+ apk: "application/vnd.android.package-archive",
219
+ cii: "application/vnd.anser-web-certificate-issue-initiation",
220
+ fti: "application/vnd.anser-web-funds-transfer-initiation",
221
+ atx: "application/vnd.antix.game-component",
222
+ dmg: "application/x-apple-diskimage",
223
+ mpkg: "application/vnd.apple.installer+xml",
224
+ aw: "application/applixware",
225
+ mp3: "audio/mpeg",
226
+ les: "application/vnd.hhe.lesson-player",
227
+ swi: "application/vnd.aristanetworks.swi",
228
+ s: "text/x-asm",
229
+ atomcat: "application/atomcat+xml",
230
+ atomsvc: "application/atomsvc+xml",
231
+ atom: "application/atom+xml",
232
+ ac: "application/pkix-attr-cert",
233
+ aif: "audio/x-aiff",
234
+ avi: "video/x-msvideo",
235
+ aep: "application/vnd.audiograph",
236
+ dxf: "image/vnd.dxf",
237
+ dwf: "model/vnd.dwf",
238
+ par: "text/plain-bas",
239
+ bcpio: "application/x-bcpio",
240
+ bin: "application/octet-stream",
241
+ bmp: "image/bmp",
242
+ torrent: "application/x-bittorrent",
243
+ cod: "application/vnd.rim.cod",
244
+ mpm: "application/vnd.blueice.multipass",
245
+ bmi: "application/vnd.bmi",
246
+ sh: "application/x-sh",
247
+ btif: "image/prs.btif",
248
+ rep: "application/vnd.businessobjects",
249
+ bz: "application/x-bzip",
250
+ bz2: "application/x-bzip2",
251
+ csh: "application/x-csh",
252
+ c: "text/x-c",
253
+ cdxml: "application/vnd.chemdraw+xml",
254
+ css: "text/css",
255
+ cdx: "chemical/x-cdx",
256
+ cml: "chemical/x-cml",
257
+ csml: "chemical/x-csml",
258
+ cdbcmsg: "application/vnd.contact.cmsg",
259
+ cla: "application/vnd.claymore",
260
+ c4g: "application/vnd.clonk.c4group",
261
+ sub: "image/vnd.dvb.subtitle",
262
+ cdmia: "application/cdmi-capability",
263
+ cdmic: "application/cdmi-container",
264
+ cdmid: "application/cdmi-domain",
265
+ cdmio: "application/cdmi-object",
266
+ cdmiq: "application/cdmi-queue",
267
+ c11amc: "application/vnd.cluetrust.cartomobile-config",
268
+ c11amz: "application/vnd.cluetrust.cartomobile-config-pkg",
269
+ ras: "image/x-cmu-raster",
270
+ dae: "model/vnd.collada+xml",
271
+ csv: "text/csv",
272
+ cpt: "application/mac-compactpro",
273
+ wmlc: "application/vnd.wap.wmlc",
274
+ cgm: "image/cgm",
275
+ ice: "x-conference/x-cooltalk",
276
+ cmx: "image/x-cmx",
277
+ xar: "application/vnd.xara",
278
+ cmc: "application/vnd.cosmocaller",
279
+ cpio: "application/x-cpio",
280
+ clkx: "application/vnd.crick.clicker",
281
+ clkk: "application/vnd.crick.clicker.keyboard",
282
+ clkp: "application/vnd.crick.clicker.palette",
283
+ clkt: "application/vnd.crick.clicker.template",
284
+ clkw: "application/vnd.crick.clicker.wordbank",
285
+ wbs: "application/vnd.criticaltools.wbs+xml",
286
+ cryptonote: "application/vnd.rig.cryptonote",
287
+ cif: "chemical/x-cif",
288
+ cmdf: "chemical/x-cmdf",
289
+ cu: "application/cu-seeme",
290
+ cww: "application/prs.cww",
291
+ curl: "text/vnd.curl",
292
+ dcurl: "text/vnd.curl.dcurl",
293
+ mcurl: "text/vnd.curl.mcurl",
294
+ scurl: "text/vnd.curl.scurl",
295
+ car: "application/vnd.curl.car",
296
+ pcurl: "application/vnd.curl.pcurl",
297
+ cmp: "application/vnd.yellowriver-custom-menu",
298
+ dssc: "application/dssc+der",
299
+ xdssc: "application/dssc+xml",
300
+ deb: "application/x-debian-package",
301
+ uva: "audio/vnd.dece.audio",
302
+ uvi: "image/vnd.dece.graphic",
303
+ uvh: "video/vnd.dece.hd",
304
+ uvm: "video/vnd.dece.mobile",
305
+ uvu: "video/vnd.uvvu.mp4",
306
+ uvp: "video/vnd.dece.pd",
307
+ uvs: "video/vnd.dece.sd",
308
+ uvv: "video/vnd.dece.video",
309
+ dvi: "application/x-dvi",
310
+ seed: "application/vnd.fdsn.seed",
311
+ dtb: "application/x-dtbook+xml",
312
+ res: "application/x-dtbresource+xml",
313
+ ait: "application/vnd.dvb.ait",
314
+ svc: "application/vnd.dvb.service",
315
+ eol: "audio/vnd.digital-winds",
316
+ djvu: "image/vnd.djvu",
317
+ dtd: "application/xml-dtd",
318
+ mlp: "application/vnd.dolby.mlp",
319
+ wad: "application/x-doom",
320
+ dpg: "application/vnd.dpgraph",
321
+ dra: "audio/vnd.dra",
322
+ dfac: "application/vnd.dreamfactory",
323
+ dts: "audio/vnd.dts",
324
+ dtshd: "audio/vnd.dts.hd",
325
+ dwg: "image/vnd.dwg",
326
+ geo: "application/vnd.dynageo",
327
+ es: "application/ecmascript",
328
+ mag: "application/vnd.ecowin.chart",
329
+ mmr: "image/vnd.fujixerox.edmics-mmr",
330
+ rlc: "image/vnd.fujixerox.edmics-rlc",
331
+ exi: "application/exi",
332
+ mgz: "application/vnd.proteus.magazine",
333
+ epub: "application/epub+zip",
334
+ eml: "message/rfc822",
335
+ nml: "application/vnd.enliven",
336
+ xpr: "application/vnd.is-xpr",
337
+ xif: "image/vnd.xiff",
338
+ xfdl: "application/vnd.xfdl",
339
+ emma: "application/emma+xml",
340
+ ez2: "application/vnd.ezpix-album",
341
+ ez3: "application/vnd.ezpix-package",
342
+ fst: "image/vnd.fst",
343
+ fvt: "video/vnd.fvt",
344
+ fbs: "image/vnd.fastbidsheet",
345
+ fe_launch: "application/vnd.denovo.fcselayout-link",
346
+ f4v: "video/x-f4v",
347
+ flv: "video/x-flv",
348
+ fpx: "image/vnd.fpx",
349
+ npx: "image/vnd.net-fpx",
350
+ flx: "text/vnd.fmi.flexstor",
351
+ fli: "video/x-fli",
352
+ ftc: "application/vnd.fluxtime.clip",
353
+ fdf: "application/vnd.fdf",
354
+ f: "text/x-fortran",
355
+ mif: "application/vnd.mif",
356
+ fm: "application/vnd.framemaker",
357
+ fh: "image/x-freehand",
358
+ fsc: "application/vnd.fsc.weblaunch",
359
+ fnc: "application/vnd.frogans.fnc",
360
+ ltf: "application/vnd.frogans.ltf",
361
+ ddd: "application/vnd.fujixerox.ddd",
362
+ xdw: "application/vnd.fujixerox.docuworks",
363
+ xbd: "application/vnd.fujixerox.docuworks.binder",
364
+ oas: "application/vnd.fujitsu.oasys",
365
+ oa2: "application/vnd.fujitsu.oasys2",
366
+ oa3: "application/vnd.fujitsu.oasys3",
367
+ fg5: "application/vnd.fujitsu.oasysgp",
368
+ bh2: "application/vnd.fujitsu.oasysprs",
369
+ spl: "application/x-futuresplash",
370
+ fzs: "application/vnd.fuzzysheet",
371
+ g3: "image/g3fax",
372
+ gmx: "application/vnd.gmx",
373
+ gtw: "model/vnd.gtw",
374
+ txd: "application/vnd.genomatix.tuxedo",
375
+ ggb: "application/vnd.geogebra.file",
376
+ ggt: "application/vnd.geogebra.tool",
377
+ gdl: "model/vnd.gdl",
378
+ gex: "application/vnd.geometry-explorer",
379
+ gxt: "application/vnd.geonext",
380
+ g2w: "application/vnd.geoplan",
381
+ g3w: "application/vnd.geospace",
382
+ gsf: "application/x-font-ghostscript",
383
+ bdf: "application/x-font-bdf",
384
+ gtar: "application/x-gtar",
385
+ texinfo: "application/x-texinfo",
386
+ gnumeric: "application/x-gnumeric",
387
+ kml: "application/vnd.google-earth.kml+xml",
388
+ kmz: "application/vnd.google-earth.kmz",
389
+ gqf: "application/vnd.grafeq",
390
+ gif: "image/gif",
391
+ gv: "text/vnd.graphviz",
392
+ gac: "application/vnd.groove-account",
393
+ ghf: "application/vnd.groove-help",
394
+ gim: "application/vnd.groove-identity-message",
395
+ grv: "application/vnd.groove-injector",
396
+ gtm: "application/vnd.groove-tool-message",
397
+ tpl: "application/vnd.groove-tool-template",
398
+ vcg: "application/vnd.groove-vcard",
399
+ h261: "video/h261",
400
+ h263: "video/h263",
401
+ h264: "video/h264",
402
+ hpid: "application/vnd.hp-hpid",
403
+ hps: "application/vnd.hp-hps",
404
+ hdf: "application/x-hdf",
405
+ rip: "audio/vnd.rip",
406
+ hbci: "application/vnd.hbci",
407
+ jlt: "application/vnd.hp-jlyt",
408
+ pcl: "application/vnd.hp-pcl",
409
+ hpgl: "application/vnd.hp-hpgl",
410
+ hvs: "application/vnd.yamaha.hv-script",
411
+ hvd: "application/vnd.yamaha.hv-dic",
412
+ hvp: "application/vnd.yamaha.hv-voice",
413
+ "sfd-hdstx": "application/vnd.hydrostatix.sof-data",
414
+ stk: "application/hyperstudio",
415
+ hal: "application/vnd.hal+xml",
416
+ html: "text/html",
417
+ irm: "application/vnd.ibm.rights-management",
418
+ sc: "application/vnd.ibm.secure-container",
419
+ ics: "text/calendar",
420
+ icc: "application/vnd.iccprofile",
421
+ ico: "image/x-icon",
422
+ igl: "application/vnd.igloader",
423
+ ief: "image/ief",
424
+ ivp: "application/vnd.immervision-ivp",
425
+ ivu: "application/vnd.immervision-ivu",
426
+ rif: "application/reginfo+xml",
427
+ "3dml": "text/vnd.in3d.3dml",
428
+ spot: "text/vnd.in3d.spot",
429
+ igs: "model/iges",
430
+ i2g: "application/vnd.intergeo",
431
+ cdy: "application/vnd.cinderella",
432
+ xpw: "application/vnd.intercon.formnet",
433
+ fcs: "application/vnd.isac.fcs",
434
+ ipfix: "application/ipfix",
435
+ cer: "application/pkix-cert",
436
+ pki: "application/pkixcmp",
437
+ crl: "application/pkix-crl",
438
+ pkipath: "application/pkix-pkipath",
439
+ igm: "application/vnd.insors.igm",
440
+ rcprofile: "application/vnd.ipunplugged.rcprofile",
441
+ irp: "application/vnd.irepository.package+xml",
442
+ jad: "text/vnd.sun.j2me.app-descriptor",
443
+ jar: "application/java-archive",
444
+ "class": "application/java-vm",
445
+ jnlp: "application/x-java-jnlp-file",
446
+ ser: "application/java-serialized-object",
447
+ java: "text/x-java-source,java",
448
+ js: "application/javascript",
449
+ json: "application/json",
450
+ joda: "application/vnd.joost.joda-archive",
451
+ jpm: "video/jpm",
452
+ jpeg: "image/jpeg",
453
+ jpg: "image/jpeg",
454
+ pjpeg: "image/pjpeg",
455
+ jpgv: "video/jpeg",
456
+ ktz: "application/vnd.kahootz",
457
+ mmd: "application/vnd.chipnuts.karaoke-mmd",
458
+ karbon: "application/vnd.kde.karbon",
459
+ chrt: "application/vnd.kde.kchart",
460
+ kfo: "application/vnd.kde.kformula",
461
+ flw: "application/vnd.kde.kivio",
462
+ kon: "application/vnd.kde.kontour",
463
+ kpr: "application/vnd.kde.kpresenter",
464
+ ksp: "application/vnd.kde.kspread",
465
+ kwd: "application/vnd.kde.kword",
466
+ htke: "application/vnd.kenameaapp",
467
+ kia: "application/vnd.kidspiration",
468
+ kne: "application/vnd.kinar",
469
+ sse: "application/vnd.kodak-descriptor",
470
+ lasxml: "application/vnd.las.las+xml",
471
+ latex: "application/x-latex",
472
+ lbd: "application/vnd.llamagraphics.life-balance.desktop",
473
+ lbe: "application/vnd.llamagraphics.life-balance.exchange+xml",
474
+ jam: "application/vnd.jam",
475
+ "123": "application/vnd.lotus-1-2-3",
476
+ apr: "application/vnd.lotus-approach",
477
+ pre: "application/vnd.lotus-freelance",
478
+ nsf: "application/vnd.lotus-notes",
479
+ org: "application/vnd.lotus-organizer",
480
+ scm: "application/vnd.lotus-screencam",
481
+ lwp: "application/vnd.lotus-wordpro",
482
+ lvp: "audio/vnd.lucent.voice",
483
+ m3u: "audio/x-mpegurl",
484
+ m4v: "video/x-m4v",
485
+ hqx: "application/mac-binhex40",
486
+ portpkg: "application/vnd.macports.portpkg",
487
+ mgp: "application/vnd.osgeo.mapguide.package",
488
+ mrc: "application/marc",
489
+ mrcx: "application/marcxml+xml",
490
+ mxf: "application/mxf",
491
+ nbp: "application/vnd.wolfram.player",
492
+ ma: "application/mathematica",
493
+ mathml: "application/mathml+xml",
494
+ mbox: "application/mbox",
495
+ mc1: "application/vnd.medcalcdata",
496
+ mscml: "application/mediaservercontrol+xml",
497
+ cdkey: "application/vnd.mediastation.cdkey",
498
+ mwf: "application/vnd.mfer",
499
+ mfm: "application/vnd.mfmp",
500
+ msh: "model/mesh",
501
+ mads: "application/mads+xml",
502
+ mets: "application/mets+xml",
503
+ mods: "application/mods+xml",
504
+ meta4: "application/metalink4+xml",
505
+ mcd: "application/vnd.mcd",
506
+ flo: "application/vnd.micrografx.flo",
507
+ igx: "application/vnd.micrografx.igx",
508
+ es3: "application/vnd.eszigno3+xml",
509
+ mdb: "application/x-msaccess",
510
+ asf: "video/x-ms-asf",
511
+ exe: "application/x-msdownload",
512
+ cil: "application/vnd.ms-artgalry",
513
+ cab: "application/vnd.ms-cab-compressed",
514
+ ims: "application/vnd.ms-ims",
515
+ application: "application/x-ms-application",
516
+ clp: "application/x-msclip",
517
+ mdi: "image/vnd.ms-modi",
518
+ eot: "application/vnd.ms-fontobject",
519
+ xls: "application/vnd.ms-excel",
520
+ xlam: "application/vnd.ms-excel.addin.macroenabled.12",
521
+ xlsb: "application/vnd.ms-excel.sheet.binary.macroenabled.12",
522
+ xltm: "application/vnd.ms-excel.template.macroenabled.12",
523
+ xlsm: "application/vnd.ms-excel.sheet.macroenabled.12",
524
+ chm: "application/vnd.ms-htmlhelp",
525
+ crd: "application/x-mscardfile",
526
+ lrm: "application/vnd.ms-lrm",
527
+ mvb: "application/x-msmediaview",
528
+ mny: "application/x-msmoney",
529
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
530
+ sldx: "application/vnd.openxmlformats-officedocument.presentationml.slide",
531
+ ppsx: "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
532
+ potx: "application/vnd.openxmlformats-officedocument.presentationml.template",
533
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
534
+ xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
535
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
536
+ dotx: "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
537
+ obd: "application/x-msbinder",
538
+ thmx: "application/vnd.ms-officetheme",
539
+ onetoc: "application/onenote",
540
+ pya: "audio/vnd.ms-playready.media.pya",
541
+ pyv: "video/vnd.ms-playready.media.pyv",
542
+ ppt: "application/vnd.ms-powerpoint",
543
+ ppam: "application/vnd.ms-powerpoint.addin.macroenabled.12",
544
+ sldm: "application/vnd.ms-powerpoint.slide.macroenabled.12",
545
+ pptm: "application/vnd.ms-powerpoint.presentation.macroenabled.12",
546
+ ppsm: "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
547
+ potm: "application/vnd.ms-powerpoint.template.macroenabled.12",
548
+ mpp: "application/vnd.ms-project",
549
+ pub: "application/x-mspublisher",
550
+ scd: "application/x-msschedule",
551
+ xap: "application/x-silverlight-app",
552
+ stl: "application/vnd.ms-pki.stl",
553
+ cat: "application/vnd.ms-pki.seccat",
554
+ vsd: "application/vnd.visio",
555
+ vsdx: "application/vnd.visio2013",
556
+ wm: "video/x-ms-wm",
557
+ wma: "audio/x-ms-wma",
558
+ wax: "audio/x-ms-wax",
559
+ wmx: "video/x-ms-wmx",
560
+ wmd: "application/x-ms-wmd",
561
+ wpl: "application/vnd.ms-wpl",
562
+ wmz: "application/x-ms-wmz",
563
+ wmv: "video/x-ms-wmv",
564
+ wvx: "video/x-ms-wvx",
565
+ wmf: "application/x-msmetafile",
566
+ trm: "application/x-msterminal",
567
+ doc: "application/msword",
568
+ docm: "application/vnd.ms-word.document.macroenabled.12",
569
+ dotm: "application/vnd.ms-word.template.macroenabled.12",
570
+ wri: "application/x-mswrite",
571
+ wps: "application/vnd.ms-works",
572
+ xbap: "application/x-ms-xbap",
573
+ xps: "application/vnd.ms-xpsdocument",
574
+ mid: "audio/midi",
575
+ mpy: "application/vnd.ibm.minipay",
576
+ afp: "application/vnd.ibm.modcap",
577
+ rms: "application/vnd.jcp.javame.midlet-rms",
578
+ tmo: "application/vnd.tmobile-livetv",
579
+ prc: "application/x-mobipocket-ebook",
580
+ mbk: "application/vnd.mobius.mbk",
581
+ dis: "application/vnd.mobius.dis",
582
+ plc: "application/vnd.mobius.plc",
583
+ mqy: "application/vnd.mobius.mqy",
584
+ msl: "application/vnd.mobius.msl",
585
+ txf: "application/vnd.mobius.txf",
586
+ daf: "application/vnd.mobius.daf",
587
+ fly: "text/vnd.fly",
588
+ mpc: "application/vnd.mophun.certificate",
589
+ mpn: "application/vnd.mophun.application",
590
+ mj2: "video/mj2",
591
+ mpga: "audio/mpeg",
592
+ mxu: "video/vnd.mpegurl",
593
+ mpeg: "video/mpeg",
594
+ m21: "application/mp21",
595
+ mp4a: "audio/mp4",
596
+ mp4: "video/mp4",
597
+ m3u8: "application/vnd.apple.mpegurl",
598
+ mus: "application/vnd.musician",
599
+ msty: "application/vnd.muvee.style",
600
+ mxml: "application/xv+xml",
601
+ ngdat: "application/vnd.nokia.n-gage.data",
602
+ "n-gage": "application/vnd.nokia.n-gage.symbian.install",
603
+ ncx: "application/x-dtbncx+xml",
604
+ nc: "application/x-netcdf",
605
+ nlu: "application/vnd.neurolanguage.nlu",
606
+ dna: "application/vnd.dna",
607
+ nnd: "application/vnd.noblenet-directory",
608
+ nns: "application/vnd.noblenet-sealer",
609
+ nnw: "application/vnd.noblenet-web",
610
+ rpst: "application/vnd.nokia.radio-preset",
611
+ rpss: "application/vnd.nokia.radio-presets",
612
+ n3: "text/n3",
613
+ edm: "application/vnd.novadigm.edm",
614
+ edx: "application/vnd.novadigm.edx",
615
+ ext: "application/vnd.novadigm.ext",
616
+ gph: "application/vnd.flographit",
617
+ ecelp4800: "audio/vnd.nuera.ecelp4800",
618
+ ecelp7470: "audio/vnd.nuera.ecelp7470",
619
+ ecelp9600: "audio/vnd.nuera.ecelp9600",
620
+ oda: "application/oda",
621
+ ogx: "application/ogg",
622
+ oga: "audio/ogg",
623
+ ogv: "video/ogg",
624
+ dd2: "application/vnd.oma.dd2+xml",
625
+ oth: "application/vnd.oasis.opendocument.text-web",
626
+ opf: "application/oebps-package+xml",
627
+ qbo: "application/vnd.intu.qbo",
628
+ oxt: "application/vnd.openofficeorg.extension",
629
+ osf: "application/vnd.yamaha.openscoreformat",
630
+ weba: "audio/webm",
631
+ webm: "video/webm",
632
+ odc: "application/vnd.oasis.opendocument.chart",
633
+ otc: "application/vnd.oasis.opendocument.chart-template",
634
+ odb: "application/vnd.oasis.opendocument.database",
635
+ odf: "application/vnd.oasis.opendocument.formula",
636
+ odft: "application/vnd.oasis.opendocument.formula-template",
637
+ odg: "application/vnd.oasis.opendocument.graphics",
638
+ otg: "application/vnd.oasis.opendocument.graphics-template",
639
+ odi: "application/vnd.oasis.opendocument.image",
640
+ oti: "application/vnd.oasis.opendocument.image-template",
641
+ odp: "application/vnd.oasis.opendocument.presentation",
642
+ otp: "application/vnd.oasis.opendocument.presentation-template",
643
+ ods: "application/vnd.oasis.opendocument.spreadsheet",
644
+ ots: "application/vnd.oasis.opendocument.spreadsheet-template",
645
+ odt: "application/vnd.oasis.opendocument.text",
646
+ odm: "application/vnd.oasis.opendocument.text-master",
647
+ ott: "application/vnd.oasis.opendocument.text-template",
648
+ ktx: "image/ktx",
649
+ sxc: "application/vnd.sun.xml.calc",
650
+ stc: "application/vnd.sun.xml.calc.template",
651
+ sxd: "application/vnd.sun.xml.draw",
652
+ std: "application/vnd.sun.xml.draw.template",
653
+ sxi: "application/vnd.sun.xml.impress",
654
+ sti: "application/vnd.sun.xml.impress.template",
655
+ sxm: "application/vnd.sun.xml.math",
656
+ sxw: "application/vnd.sun.xml.writer",
657
+ sxg: "application/vnd.sun.xml.writer.global",
658
+ stw: "application/vnd.sun.xml.writer.template",
659
+ otf: "application/x-font-otf",
660
+ osfpvg: "application/vnd.yamaha.openscoreformat.osfpvg+xml",
661
+ dp: "application/vnd.osgi.dp",
662
+ pdb: "application/vnd.palm",
663
+ p: "text/x-pascal",
664
+ paw: "application/vnd.pawaafile",
665
+ pclxl: "application/vnd.hp-pclxl",
666
+ efif: "application/vnd.picsel",
667
+ pcx: "image/x-pcx",
668
+ psd: "image/vnd.adobe.photoshop",
669
+ prf: "application/pics-rules",
670
+ pic: "image/x-pict",
671
+ chat: "application/x-chat",
672
+ p10: "application/pkcs10",
673
+ p12: "application/x-pkcs12",
674
+ p7m: "application/pkcs7-mime",
675
+ p7s: "application/pkcs7-signature",
676
+ p7r: "application/x-pkcs7-certreqresp",
677
+ p7b: "application/x-pkcs7-certificates",
678
+ p8: "application/pkcs8",
679
+ plf: "application/vnd.pocketlearn",
680
+ pnm: "image/x-portable-anymap",
681
+ pbm: "image/x-portable-bitmap",
682
+ pcf: "application/x-font-pcf",
683
+ pfr: "application/font-tdpfr",
684
+ pgn: "application/x-chess-pgn",
685
+ pgm: "image/x-portable-graymap",
686
+ png: "image/png",
687
+ ppm: "image/x-portable-pixmap",
688
+ pskcxml: "application/pskc+xml",
689
+ pml: "application/vnd.ctc-posml",
690
+ ai: "application/postscript",
691
+ pfa: "application/x-font-type1",
692
+ pbd: "application/vnd.powerbuilder6",
693
+ pgp: "application/pgp-signature",
694
+ box: "application/vnd.previewsystems.box",
695
+ ptid: "application/vnd.pvi.ptid1",
696
+ pls: "application/pls+xml",
697
+ str: "application/vnd.pg.format",
698
+ ei6: "application/vnd.pg.osasli",
699
+ dsc: "text/prs.lines.tag",
700
+ psf: "application/x-font-linux-psf",
701
+ qps: "application/vnd.publishare-delta-tree",
702
+ wg: "application/vnd.pmi.widget",
703
+ qxd: "application/vnd.quark.quarkxpress",
704
+ esf: "application/vnd.epson.esf",
705
+ msf: "application/vnd.epson.msf",
706
+ ssf: "application/vnd.epson.ssf",
707
+ qam: "application/vnd.epson.quickanime",
708
+ qfx: "application/vnd.intu.qfx",
709
+ qt: "video/quicktime",
710
+ rar: "application/x-rar-compressed",
711
+ ram: "audio/x-pn-realaudio",
712
+ rmp: "audio/x-pn-realaudio-plugin",
713
+ rsd: "application/rsd+xml",
714
+ rm: "application/vnd.rn-realmedia",
715
+ bed: "application/vnd.realvnc.bed",
716
+ mxl: "application/vnd.recordare.musicxml",
717
+ musicxml: "application/vnd.recordare.musicxml+xml",
718
+ rnc: "application/relax-ng-compact-syntax",
719
+ rdz: "application/vnd.data-vision.rdz",
720
+ rdf: "application/rdf+xml",
721
+ rp9: "application/vnd.cloanto.rp9",
722
+ jisp: "application/vnd.jisp",
723
+ rtf: "application/rtf",
724
+ rtx: "text/richtext",
725
+ link66: "application/vnd.route66.link66+xml",
726
+ rss: "application/rss+xml",
727
+ shf: "application/shf+xml",
728
+ st: "application/vnd.sailingtracker.track",
729
+ svg: "image/svg+xml",
730
+ sus: "application/vnd.sus-calendar",
731
+ sru: "application/sru+xml",
732
+ setpay: "application/set-payment-initiation",
733
+ setreg: "application/set-registration-initiation",
734
+ sema: "application/vnd.sema",
735
+ semd: "application/vnd.semd",
736
+ semf: "application/vnd.semf",
737
+ see: "application/vnd.seemail",
738
+ snf: "application/x-font-snf",
739
+ spq: "application/scvp-vp-request",
740
+ spp: "application/scvp-vp-response",
741
+ scq: "application/scvp-cv-request",
742
+ scs: "application/scvp-cv-response",
743
+ sdp: "application/sdp",
744
+ etx: "text/x-setext",
745
+ movie: "video/x-sgi-movie",
746
+ ifm: "application/vnd.shana.informed.formdata",
747
+ itp: "application/vnd.shana.informed.formtemplate",
748
+ iif: "application/vnd.shana.informed.interchange",
749
+ ipk: "application/vnd.shana.informed.package",
750
+ tfi: "application/thraud+xml",
751
+ shar: "application/x-shar",
752
+ rgb: "image/x-rgb",
753
+ slt: "application/vnd.epson.salt",
754
+ aso: "application/vnd.accpac.simply.aso",
755
+ imp: "application/vnd.accpac.simply.imp",
756
+ twd: "application/vnd.simtech-mindmapper",
757
+ csp: "application/vnd.commonspace",
758
+ saf: "application/vnd.yamaha.smaf-audio",
759
+ mmf: "application/vnd.smaf",
760
+ spf: "application/vnd.yamaha.smaf-phrase",
761
+ teacher: "application/vnd.smart.teacher",
762
+ svd: "application/vnd.svd",
763
+ rq: "application/sparql-query",
764
+ srx: "application/sparql-results+xml",
765
+ gram: "application/srgs",
766
+ grxml: "application/srgs+xml",
767
+ ssml: "application/ssml+xml",
768
+ skp: "application/vnd.koan",
769
+ sgml: "text/sgml",
770
+ sdc: "application/vnd.stardivision.calc",
771
+ sda: "application/vnd.stardivision.draw",
772
+ sdd: "application/vnd.stardivision.impress",
773
+ smf: "application/vnd.stardivision.math",
774
+ sdw: "application/vnd.stardivision.writer",
775
+ sgl: "application/vnd.stardivision.writer-global",
776
+ sm: "application/vnd.stepmania.stepchart",
777
+ sit: "application/x-stuffit",
778
+ sitx: "application/x-stuffitx",
779
+ sdkm: "application/vnd.solent.sdkm+xml",
780
+ xo: "application/vnd.olpc-sugar",
781
+ au: "audio/basic",
782
+ wqd: "application/vnd.wqd",
783
+ sis: "application/vnd.symbian.install",
784
+ smi: "application/smil+xml",
785
+ xsm: "application/vnd.syncml+xml",
786
+ bdm: "application/vnd.syncml.dm+wbxml",
787
+ xdm: "application/vnd.syncml.dm+xml",
788
+ sv4cpio: "application/x-sv4cpio",
789
+ sv4crc: "application/x-sv4crc",
790
+ sbml: "application/sbml+xml",
791
+ tsv: "text/tab-separated-values",
792
+ tiff: "image/tiff",
793
+ tao: "application/vnd.tao.intent-module-archive",
794
+ tar: "application/x-tar",
795
+ tcl: "application/x-tcl",
796
+ tex: "application/x-tex",
797
+ tfm: "application/x-tex-tfm",
798
+ tei: "application/tei+xml",
799
+ txt: "text/plain",
800
+ dxp: "application/vnd.spotfire.dxp",
801
+ sfs: "application/vnd.spotfire.sfs",
802
+ tsd: "application/timestamped-data",
803
+ tpt: "application/vnd.trid.tpt",
804
+ mxs: "application/vnd.triscape.mxs",
805
+ t: "text/troff",
806
+ tra: "application/vnd.trueapp",
807
+ ttf: "application/x-font-ttf",
808
+ ttl: "text/turtle",
809
+ umj: "application/vnd.umajin",
810
+ uoml: "application/vnd.uoml+xml",
811
+ unityweb: "application/vnd.unity",
812
+ ufd: "application/vnd.ufdl",
813
+ uri: "text/uri-list",
814
+ utz: "application/vnd.uiq.theme",
815
+ ustar: "application/x-ustar",
816
+ uu: "text/x-uuencode",
817
+ vcs: "text/x-vcalendar",
818
+ vcf: "text/x-vcard",
819
+ vcd: "application/x-cdlink",
820
+ vsf: "application/vnd.vsf",
821
+ wrl: "model/vrml",
822
+ vcx: "application/vnd.vcx",
823
+ mts: "model/vnd.mts",
824
+ vtu: "model/vnd.vtu",
825
+ vis: "application/vnd.visionary",
826
+ viv: "video/vnd.vivo",
827
+ ccxml: "application/ccxml+xml,",
828
+ vxml: "application/voicexml+xml",
829
+ src: "application/x-wais-source",
830
+ wbxml: "application/vnd.wap.wbxml",
831
+ wbmp: "image/vnd.wap.wbmp",
832
+ wav: "audio/x-wav",
833
+ davmount: "application/davmount+xml",
834
+ woff: "application/x-font-woff",
835
+ wspolicy: "application/wspolicy+xml",
836
+ webp: "image/webp",
837
+ wtb: "application/vnd.webturbo",
838
+ wgt: "application/widget",
839
+ hlp: "application/winhlp",
840
+ wml: "text/vnd.wap.wml",
841
+ wmls: "text/vnd.wap.wmlscript",
842
+ wmlsc: "application/vnd.wap.wmlscriptc",
843
+ wpd: "application/vnd.wordperfect",
844
+ stf: "application/vnd.wt.stf",
845
+ wsdl: "application/wsdl+xml",
846
+ xbm: "image/x-xbitmap",
847
+ xpm: "image/x-xpixmap",
848
+ xwd: "image/x-xwindowdump",
849
+ der: "application/x-x509-ca-cert",
850
+ fig: "application/x-xfig",
851
+ xhtml: "application/xhtml+xml",
852
+ xml: "application/xml",
853
+ xdf: "application/xcap-diff+xml",
854
+ xenc: "application/xenc+xml",
855
+ xer: "application/patch-ops-error+xml",
856
+ rl: "application/resource-lists+xml",
857
+ rs: "application/rls-services+xml",
858
+ rld: "application/resource-lists-diff+xml",
859
+ xslt: "application/xslt+xml",
860
+ xop: "application/xop+xml",
861
+ xpi: "application/x-xpinstall",
862
+ xspf: "application/xspf+xml",
863
+ xul: "application/vnd.mozilla.xul+xml",
864
+ xyz: "chemical/x-xyz",
865
+ yaml: "text/yaml",
866
+ yang: "application/yang",
867
+ yin: "application/yin+xml",
868
+ zir: "application/vnd.zul",
869
+ zip: "application/zip",
870
+ zmm: "application/vnd.handheld-entertainment+xml",
871
+ zaz: "application/vnd.zzazz.deck+xml"
872
+ };
873
+
874
+ // TODO: write this out to avoid compute
875
+ var MIME_TYPES_TO_EXT = Object.fromEntries(Object.entries(EXT_TO_MIME_TYPES).map(function (_ref) {
876
+ var _ref2 = _slicedToArray(_ref, 2),
877
+ k = _ref2[0],
878
+ v = _ref2[1];
879
+ return [v, k];
880
+ }));
881
+
882
+ var MIME_TYPE_REGEX = /^data:(.*?);base64,/;
183
883
  function getMimeType(base64Url) {
184
884
  var match = MIME_TYPE_REGEX.exec(base64Url);
185
885
  if (match && match[1]) {
@@ -188,41 +888,32 @@ function getMimeType(base64Url) {
188
888
  return;
189
889
  }
190
890
  function mimeTypeToFileExt(mimeType) {
191
- if (mimeType === "image/svg+xml") {
192
- return "svg";
193
- }
194
- if (mimeType === "image/vnd.microsoft.icon") {
195
- return "ico";
196
- }
197
- if (mimeType.startsWith("image/")) {
198
- return mimeType.slice("image/".length);
891
+ var recognizedMimeType = MIME_TYPES_TO_EXT[mimeType];
892
+ if (recognizedMimeType) {
893
+ return recognizedMimeType;
199
894
  }
200
- return mimeType;
895
+ return mimeType.split("/")[1];
201
896
  }
202
897
  function filenameToMimeType(filename) {
203
898
  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";
899
+ var recognizedExt = ext && EXT_TO_MIME_TYPES[ext];
900
+ if (recognizedExt) {
901
+ return recognizedExt;
212
902
  }
213
- return "image/".concat(imageType);
214
903
  }
215
904
 
216
- var HeaderRegEx = /^h([\d+])$/;
217
- function lexicalToRichTextSource(node) {
218
- var markdownIRBlocks = node.children.map(createBlock);
219
- return fromIRToRichTextSource(markdownIRBlocks);
905
+ function remirrorToRichTextSource(node) {
906
+ var files = {};
907
+ var markdownIRBlocks = node.content.map(function (child) {
908
+ return createBlock(child, files);
909
+ });
910
+ return fromIRToRichTextSource(markdownIRBlocks, files);
220
911
  }
221
- function createBlock(node) {
912
+ function createBlock(node, files) {
222
913
  if (node.type === "heading") {
223
- var _node$tag$match;
914
+ var _node$attrs, _node$content;
224
915
  var headingTag = "";
225
- var depth = Number((_node$tag$match = node.tag.match(HeaderRegEx)) === null || _node$tag$match === void 0 ? void 0 : _node$tag$match[1]);
916
+ var depth = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.level) || 1;
226
917
  if (Number.isNaN(depth)) {
227
918
  throw new Error("Invalid header depth");
228
919
  }
@@ -232,10 +923,13 @@ function createBlock(node) {
232
923
  var headingText = ["".concat(headingTag, " ")];
233
924
  return {
234
925
  type: "block",
235
- children: headingText.concat.apply(headingText, _toConsumableArray(node.children.map(transformLeafNode)))
926
+ children: headingText.concat.apply(headingText, _toConsumableArray(((_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.map(function (child) {
927
+ return transformLeafNode(child, files);
928
+ })) || []))
236
929
  };
237
930
  } else if (node.type === "paragraph") {
238
- if (node.children.length === 0) {
931
+ var _node$content2;
932
+ if (!node.content || ((_node$content2 = node.content) === null || _node$content2 === void 0 ? void 0 : _node$content2.length) === 0) {
239
933
  return {
240
934
  type: "block",
241
935
  children: ["<br />"]
@@ -243,26 +937,26 @@ function createBlock(node) {
243
937
  }
244
938
  return {
245
939
  type: "block",
246
- children: node.children.map(function (child) {
247
- return transformLeafNode(child);
940
+ children: node.content.map(function (child) {
941
+ return transformLeafNode(child, files);
248
942
  })
249
943
  };
250
- } else if (node.type === "list") {
944
+ } else if (node.type === "bulletList" || node.type === "orderedList") {
945
+ var _node$content3;
251
946
  return {
252
947
  type: "block",
253
- children: node.children.flatMap(function (child, i) {
254
- return formatListItemNode(getListPrefix(node), child, 0, i === 0);
255
- })
948
+ children: ((_node$content3 = node.content) === null || _node$content3 === void 0 ? void 0 : _node$content3.flatMap(function (child, i) {
949
+ return formatListItemNode(getListPrefix(node), child, 0, files, i === 0);
950
+ })) || []
256
951
  };
257
952
  } else {
258
953
  var exhaustiveCheck = node;
259
954
  throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
260
955
  }
261
956
  }
262
- function fromIRToRichTextSource(markdownIRBlocks) {
957
+ function fromIRToRichTextSource(markdownIRBlocks, files) {
263
958
  var templateStrings = ["\n"];
264
959
  var exprs = [];
265
- var files = {};
266
960
  for (var blockIdx = 0; blockIdx < markdownIRBlocks.length; blockIdx++) {
267
961
  var block = markdownIRBlocks[blockIdx];
268
962
  var _iterator = _createForOfIteratorHelper(block.children),
@@ -273,10 +967,10 @@ function fromIRToRichTextSource(markdownIRBlocks) {
273
967
  if (typeof child === "string") {
274
968
  templateStrings[templateStrings.length - 1] += child;
275
969
  } else {
276
- if (child.type === "image") {
277
- exprs.push(fromLexicalImageNode(child, files));
278
- } else if (child.type === "link") {
279
- exprs.push(fromLexicalLinkNode(child));
970
+ if (child._type === "file") {
971
+ exprs.push(child);
972
+ } else if (child._type === "link") {
973
+ exprs.push(child);
280
974
  } else {
281
975
  var exhaustiveCheck = child;
282
976
  throw new Error("Unexpected node type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
@@ -298,7 +992,17 @@ function fromIRToRichTextSource(markdownIRBlocks) {
298
992
  return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "richtext"), "templateStrings", templateStrings), "exprs", exprs), "files", files);
299
993
  }
300
994
  function formatText(node) {
301
- var classes = typeof node.format === "number" ? fromLexicalFormat(node.format) : [];
995
+ var _node$marks;
996
+ var classes = ((_node$marks = node.marks) === null || _node$marks === void 0 ? void 0 : _node$marks.flatMap(function (mark) {
997
+ if (mark.type === "bold") {
998
+ return ["bold"];
999
+ } else if (mark.type === "italic") {
1000
+ return ["italic"];
1001
+ } else if (mark.type === "strike") {
1002
+ return ["line-through"];
1003
+ }
1004
+ return [];
1005
+ })) || [];
302
1006
  var text = node.text.trimStart();
303
1007
  var prefixWS = node.text.length - text.length;
304
1008
  text = text.trimEnd();
@@ -317,87 +1021,94 @@ function formatText(node) {
317
1021
  // text = splitIntoChunks(text);
318
1022
  return "".concat(" ".repeat(prefixWS)).concat(text).concat(" ".repeat(suffixWS));
319
1023
  }
320
- function transformLeafNode(node) {
1024
+ function transformLeafNode(node, files) {
321
1025
  if (node.type === "text") {
1026
+ var _node$marks2;
1027
+ var linkMark = (_node$marks2 = node.marks) === null || _node$marks2 === void 0 ? void 0 : _node$marks2.find(function (mark) {
1028
+ return mark.type === "link";
1029
+ });
1030
+ if ((linkMark === null || linkMark === void 0 ? void 0 : linkMark.type) === "link") {
1031
+ return {
1032
+ _type: "link",
1033
+ href: linkMark.attrs.href,
1034
+ children: [formatText(node)]
1035
+ };
1036
+ }
322
1037
  return formatText(node);
323
- } else if (node.type === "linebreak") {
324
- return "\n";
1038
+ } else if (node.type === "hardBreak") {
1039
+ return "<br />";
1040
+ } else if (node.type === "image") {
1041
+ return fromRemirrorImageNode(node, files);
325
1042
  } else {
326
- return node;
1043
+ var exhaustiveCheck = node;
1044
+ throw new Error("Unexpected node type: ".concat(JSON.stringify(exhaustiveCheck)));
327
1045
  }
328
1046
  }
329
- function formatListItemNode(listPrefix, node, indent) {
330
- var _node$children;
331
- var isFirstTopLevelListItem = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
1047
+ function formatListItemNode(listPrefix, node, indent, files) {
1048
+ var _node$content4, _node$content5;
1049
+ var isFirstTopLevelListItem = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
332
1050
  var newLine = isFirstTopLevelListItem ? "" : "\n";
333
1051
  var prefix = ["".concat(newLine).concat(" ".repeat(indent)).concat(listPrefix)];
334
- if (((_node$children = node.children) === null || _node$children === void 0 || (_node$children = _node$children[0]) === null || _node$children === void 0 ? void 0 : _node$children.type) !== "list") {
1052
+ if (!(((_node$content4 = node.content) === null || _node$content4 === void 0 || (_node$content4 = _node$content4[0]) === null || _node$content4 === void 0 ? void 0 : _node$content4.type) === "bulletList" || ((_node$content5 = node.content) === null || _node$content5 === void 0 || (_node$content5 = _node$content5[0]) === null || _node$content5 === void 0 ? void 0 : _node$content5.type) === "orderedList")) {
335
1053
  prefix.push(" ");
336
1054
  }
337
- return prefix.concat(node.children.flatMap(function (child) {
338
- if (child.type === "list") {
339
- return child.children.flatMap(function (subChild) {
340
- return formatListItemNode(getListPrefix(child), subChild, indent + 4);
1055
+ return prefix.concat((node.content || []).flatMap(function (child, i) {
1056
+ if (child.type === "bulletList" || child.type === "orderedList") {
1057
+ return (child.content || []).flatMap(function (subChild) {
1058
+ return formatListItemNode(getListPrefix(child), subChild, indent + 4, files);
341
1059
  });
342
1060
  } else {
343
- return [transformLeafNode(child)];
1061
+ return (child.content || []).flatMap(function (subChild) {
1062
+ var _child$content, _child$content2;
1063
+ var res = [];
1064
+ if ((_child$content = child.content) !== null && _child$content !== void 0 && _child$content.length && ((_child$content2 = child.content) === null || _child$content2 === void 0 ? void 0 : _child$content2.length) > 0 && i > 0) {
1065
+ res.push("<br />\n");
1066
+ }
1067
+ res.push(transformLeafNode(subChild, files));
1068
+ return res;
1069
+ });
344
1070
  }
345
1071
  }));
346
1072
  }
347
1073
  function getListPrefix(node) {
348
- if (node.listType === "bullet") {
1074
+ if (node.type === "bulletList") {
349
1075
  return "-";
350
- } else if (node.listType === "number") {
1076
+ } else if (node.type === "orderedList") {
351
1077
  return "1.";
352
1078
  } else {
353
- throw new Error("Unhandled list type: ".concat(node.listType));
1079
+ var exhaustiveCheck = node;
1080
+ throw new Error("Unhandled list node: ".concat(JSON.stringify(exhaustiveCheck)));
354
1081
  }
355
1082
  }
356
- var FORMAT_MAPPING$1 = {
357
- bold: 1,
358
- // 0001
359
- italic: 2,
360
- // 0010
361
- "line-through": 4 // 0100
362
- // underline: 8, // 1000
363
- };
364
-
365
- function fromLexicalFormat(format) {
366
- return Object.entries(FORMAT_MAPPING$1).flatMap(function (_ref2) {
367
- var _ref3 = _slicedToArray(_ref2, 2),
368
- key = _ref3[0],
369
- value = _ref3[1];
370
- if ((value & /* bitwise and */format) === value) {
371
- return [key];
372
- }
373
- return [];
374
- });
375
- }
376
1083
  var textEncoder = new TextEncoder();
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);
1084
+ function fromRemirrorImageNode(node, files) {
1085
+ if (node.attrs && node.attrs.src.startsWith("data:")) {
1086
+ var sha256 = core.Internal.getSHA256Hash(textEncoder.encode(node.attrs.src));
1087
+ var mimeType = getMimeType(node.attrs.src);
381
1088
  if (mimeType === undefined) {
382
- throw new Error("Could not detect Mime Type for image: ".concat(node.src));
1089
+ throw new Error("Could not detect Mime Type for image: ".concat(node.attrs.src));
383
1090
  }
384
1091
  var fileExt = mimeTypeToFileExt(mimeType);
385
- var filePath = "/public/".concat(sha256, ".").concat(fileExt);
386
- files[filePath] = node.src;
1092
+ var fileName = node.attrs.fileName || "".concat(sha256, ".").concat(fileExt);
1093
+ var filePath = "/public/".concat(fileName);
1094
+ files[filePath] = node.attrs.src;
387
1095
  return _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), "metadata", {
388
- width: node.width || 0,
389
- height: node.height || 0,
1096
+ width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
1097
+ height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
390
1098
  sha256: sha256 || "",
391
1099
  mimeType: mimeType
392
1100
  });
393
- } else {
394
- var _sha = getParam("sha256", node.src);
395
- return _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, "/public".concat(node.src.split("?")[0])), "metadata", {
396
- width: node.width || 0,
397
- height: node.height || 0,
1101
+ } else if (node.attrs) {
1102
+ var _sha = getParam("sha256", node.attrs.src);
1103
+ var noParamsSrc = node.attrs.src.split("?")[0];
1104
+ return _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, "/public".concat(node.attrs.src.split("?")[0])), "metadata", {
1105
+ width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
1106
+ height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
398
1107
  sha256: _sha || "",
399
- mimeType: node.mimeType || ""
1108
+ mimeType: noParamsSrc && filenameToMimeType(noParamsSrc) || ""
400
1109
  });
1110
+ } else {
1111
+ throw new Error("Invalid image node (no attrs): " + JSON.stringify(node));
401
1112
  }
402
1113
  }
403
1114
  function getParam(param, url) {
@@ -412,196 +1123,6 @@ function getParam(param, url) {
412
1123
  }
413
1124
  return undefined;
414
1125
  }
415
- function fromLexicalLinkNode(node) {
416
- return _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "link"), "href", node.url), "children", node.children.map(formatText));
417
- }
418
-
419
- function ownKeys(e, r) {
420
- var t = Object.keys(e);
421
- if (Object.getOwnPropertySymbols) {
422
- var o = Object.getOwnPropertySymbols(e);
423
- r && (o = o.filter(function (r) {
424
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
425
- })), t.push.apply(t, o);
426
- }
427
- return t;
428
- }
429
- function _objectSpread2(e) {
430
- for (var r = 1; r < arguments.length; r++) {
431
- var t = null != arguments[r] ? arguments[r] : {};
432
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
433
- _defineProperty(e, r, t[r]);
434
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
435
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
436
- });
437
- }
438
- return e;
439
- }
440
-
441
- /// Serialized Lexical Nodes:
442
- // TODO: replace with Lexical libs types - not currently exported?
443
- var COMMON_LEXICAL_PROPS = {
444
- version: 1,
445
- format: "",
446
- indent: 0,
447
- direction: null
448
- };
449
- function toLexicalNode(node) {
450
- var useBreakNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
451
- if (typeof node === "string") {
452
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
453
- type: "text",
454
- format: "",
455
- text: node
456
- });
457
- }
458
- if ("tag" in node) {
459
- switch (node.tag) {
460
- case "h1":
461
- return toLexicalHeadingNode(node);
462
- case "h2":
463
- return toLexicalHeadingNode(node);
464
- case "h3":
465
- return toLexicalHeadingNode(node);
466
- case "h4":
467
- return toLexicalHeadingNode(node);
468
- case "h5":
469
- return toLexicalHeadingNode(node);
470
- case "h6":
471
- return toLexicalHeadingNode(node);
472
- case "li":
473
- return toLexicalListItemNode(node);
474
- case "p":
475
- return toLexicalParagraphNode(node);
476
- case "ul":
477
- return toLexicalListNode(node);
478
- case "ol":
479
- return toLexicalListNode(node);
480
- case "span":
481
- return toLexicalTextNode(node);
482
- case "a":
483
- return toLexicalLinkNode(node);
484
- case "img":
485
- return toLexicalImageNode(node);
486
- case "br":
487
- if (useBreakNode) {
488
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
489
- type: "linebreak"
490
- });
491
- }
492
- return toLexicalPseudoLineBreakNode();
493
- default:
494
- throw Error("Unexpected node tag: " + JSON.stringify(node, null, 2));
495
- }
496
- } else {
497
- throw Error("Unexpected node: " + JSON.stringify(node, null, 2));
498
- }
499
- }
500
- function toLexicalImageNode(node) {
501
- var url = node.src;
502
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
503
- type: "image",
504
- src: url,
505
- width: node.width,
506
- height: node.height,
507
- mimeType: node.mimeType
508
- // TODO: altText
509
- });
510
- }
511
-
512
- function toLexicalLinkNode(link) {
513
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
514
- type: "link",
515
- url: link.href,
516
- children: link.children.map(function (child) {
517
- return toLexicalNode(child);
518
- })
519
- });
520
- }
521
- function richTextSourceToLexical(richtext) {
522
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
523
- format: "",
524
- type: "root",
525
- children: richtext.children.map(function (child) {
526
- return toLexicalNode(child);
527
- })
528
- });
529
- }
530
- function toLexicalHeadingNode(heading) {
531
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
532
- type: "heading",
533
- tag: heading.tag,
534
- children: heading.children.map(function (child) {
535
- return toLexicalNode(child);
536
- })
537
- });
538
- }
539
- function toLexicalParagraphNode(paragraph) {
540
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
541
- type: "paragraph",
542
- children: paragraph.children.map(function (child) {
543
- return toLexicalNode(child, true);
544
- })
545
- });
546
- }
547
-
548
- // Lexical does not support line breaks, so we convert them to empty paragraphs
549
- function toLexicalPseudoLineBreakNode() {
550
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
551
- type: "paragraph",
552
- children: []
553
- });
554
- }
555
- function toLexicalListItemNode(listItem) {
556
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
557
- type: "listitem",
558
- children: listItem.children.map(function (child) {
559
- return toLexicalNode(child, true);
560
- })
561
- });
562
- }
563
- function toLexicalListNode(list) {
564
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
565
- type: "list",
566
- listType: list.tag === "ol" ? "number" : "bullet",
567
- children: list.children.map(function (child) {
568
- return toLexicalNode(child);
569
- })
570
- }, list.dir ? {
571
- direction: list.dir
572
- } : {
573
- direction: null
574
- });
575
- }
576
- var FORMAT_MAPPING = {
577
- bold: 1,
578
- // 0001
579
- italic: 2,
580
- // 0010
581
- "line-through": 4 // 0100
582
- // underline: 8, // 1000
583
- };
584
-
585
- function toLexicalFormat(classes) {
586
- return classes.reduce(function (prev, curr) {
587
- return prev | /* bitwise or */FORMAT_MAPPING[curr];
588
- }, 0);
589
- }
590
- function toLexicalTextNode(spanNode) {
591
- var child = spanNode.children[0];
592
- if (typeof child === "string") {
593
- return _objectSpread2(_objectSpread2({}, COMMON_LEXICAL_PROPS), {}, {
594
- type: "text",
595
- text: child,
596
- format: toLexicalFormat(spanNode.classes)
597
- });
598
- } else {
599
- // recurse the spans and merge their classes
600
- return toLexicalTextNode(_objectSpread2(_objectSpread2({}, child), {}, {
601
- classes: spanNode.classes.concat(child.classes)
602
- }));
603
- }
604
- }
605
1126
 
606
1127
  var VAL_START_TAG_PREFIX = '<val value="';
607
1128
  var VAL_START_TAG_SUFFIX = '">';
@@ -609,6 +1130,18 @@ var VAL_END_TAG = "</val>";
609
1130
  function parseTokens(tokens, sourceNodes, cursor) {
610
1131
  var insideList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
611
1132
  var children = [];
1133
+ function merge(token, clazz) {
1134
+ var parsedTokens = parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0);
1135
+ children.push({
1136
+ tag: "span",
1137
+ classes: [clazz].concat(parsedTokens.children.flatMap(function (child) {
1138
+ return typeof child === "string" ? [] : child.classes;
1139
+ })),
1140
+ children: parsedTokens.children.flatMap(function (child) {
1141
+ return typeof child === "string" ? child : child.children;
1142
+ })
1143
+ });
1144
+ }
612
1145
  var _loop = function _loop() {
613
1146
  var token = tokens[cursor];
614
1147
  if (token.type === "heading") {
@@ -622,23 +1155,11 @@ function parseTokens(tokens, sourceNodes, cursor) {
622
1155
  children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
623
1156
  });
624
1157
  } else if (token.type === "strong") {
625
- children.push({
626
- tag: "span",
627
- classes: ["bold"],
628
- children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
629
- });
1158
+ merge(token, "bold");
630
1159
  } else if (token.type === "em") {
631
- children.push({
632
- tag: "span",
633
- classes: ["italic"],
634
- children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
635
- });
1160
+ merge(token, "italic");
636
1161
  } else if (token.type === "del") {
637
- children.push({
638
- tag: "span",
639
- classes: ["line-through"],
640
- children: parseTokens(token.tokens ? token.tokens : [], sourceNodes, 0).children
641
- });
1162
+ merge(token, "line-through");
642
1163
  } else if (token.type === "text") {
643
1164
  if ("tokens" in token && Array.isArray(token.tokens)) {
644
1165
  children.push.apply(children, _toConsumableArray(parseTokens(token.tokens, sourceNodes, cursor, insideList).children));
@@ -647,6 +1168,11 @@ function parseTokens(tokens, sourceNodes, cursor) {
647
1168
  var lines = token.raw.split("\n");
648
1169
  var tags = lines.flatMap(function (line, i) {
649
1170
  if (i === lines.length - 1) return [line];
1171
+ if (i === lines.length - 1 && line === "") return [];
1172
+ if (line === "") return {
1173
+ tag: "br",
1174
+ children: []
1175
+ };
650
1176
  return [line, {
651
1177
  tag: "br",
652
1178
  children: []
@@ -716,10 +1242,16 @@ function parseTokens(tokens, sourceNodes, cursor) {
716
1242
  }
717
1243
  var br_html_regex = /<br\s*\/?>/gi; // matches <br>, <br/>, <br />; case insensitive
718
1244
  if (token.text.trim().match(br_html_regex)) {
1245
+ var _tokens;
719
1246
  children.push({
720
1247
  tag: "br",
721
1248
  children: []
722
1249
  });
1250
+ if (((_tokens = tokens[cursor + 1]) === null || _tokens === void 0 ? void 0 : _tokens.raw.trim()) === "") {
1251
+ // if next token is a new line or white-spaces, skip it
1252
+ // this typically means we have a <br> AND a new line, which, semantically, is just a <br>
1253
+ cursor++;
1254
+ }
723
1255
  }
724
1256
  } else if (token.type === "link") {
725
1257
  if (token.raw === token.href) {
@@ -779,21 +1311,359 @@ function parseRichTextSource(_ref) {
779
1311
  return _defineProperty(_defineProperty({}, core.VAL_EXTENSION, "richtext"), "children", children);
780
1312
  }
781
1313
 
1314
+ var RemirrorTextMark = zod.z.object({
1315
+ type: zod.z.union([zod.z.literal("bold"), zod.z.literal("strike"), zod.z.literal("italic")])
1316
+ });
1317
+ var RemirrorLinkMark = zod.z.object({
1318
+ type: zod.z.literal("link"),
1319
+ attrs: zod.z.object({
1320
+ href: zod.z.string(),
1321
+ target: zod.z.union([zod.z.literal("_blank"), zod.z["null"]()]),
1322
+ auto: zod.z["boolean"]()
1323
+ })
1324
+ });
1325
+ var RemirrorText = zod.z.intersection(zod.z.object({
1326
+ type: zod.z.literal("text"),
1327
+ text: zod.z.string()
1328
+ }), zod.z.object({
1329
+ marks: zod.z.array(zod.z.union([RemirrorTextMark, RemirrorLinkMark]))
1330
+ }).partial());
1331
+ var RemirrorBr = zod.z.intersection(zod.z.object({
1332
+ type: zod.z.literal("hardBreak")
1333
+ }), zod.z.object({
1334
+ marks: zod.z.array(RemirrorTextMark)
1335
+ }).partial());
1336
+ var RemirrorImage = zod.z.intersection(zod.z.object({
1337
+ type: zod.z.literal("image")
1338
+ }), zod.z.object({
1339
+ attrs: zod.z.intersection(zod.z.object({
1340
+ src: zod.z.string()
1341
+ }), zod.z.object({
1342
+ align: zod.z.union([zod.z.literal("center"), zod.z.literal("end"), zod.z.literal("justify"), zod.z.literal("left"), zod.z.literal("match-parent"), zod.z.literal("right"), zod.z.literal("start"), zod.z["null"]()]),
1343
+ alt: zod.z.union([zod.z.string(), zod.z["null"]()]),
1344
+ height: zod.z.union([zod.z.string(), zod.z.number(), zod.z["null"]()]),
1345
+ width: zod.z.union([zod.z.string(), zod.z.number(), zod.z["null"]()]),
1346
+ rotate: zod.z.union([zod.z.string(), zod.z["null"]()]),
1347
+ title: zod.z.union([zod.z.string(), zod.z["null"]()]),
1348
+ fileName: zod.z.union([zod.z.string(), zod.z["null"]()])
1349
+ }).partial())
1350
+ }).partial());
1351
+ var RemirrorHeading = zod.z.intersection(zod.z.object({
1352
+ type: zod.z.literal("heading")
1353
+ }), zod.z.object({
1354
+ attrs: zod.z.object({
1355
+ level: zod.z.number()
1356
+ }),
1357
+ content: zod.z.array(zod.z.union([RemirrorText, RemirrorBr]))
1358
+ }).partial());
1359
+ var RemirrorBulletList = zod.z.lazy(function () {
1360
+ return zod.z.intersection(zod.z.object({
1361
+ type: zod.z.literal("bulletList")
1362
+ }), zod.z.object({
1363
+ content: zod.z.array(RemirrorListItem)
1364
+ }).partial());
1365
+ });
1366
+ var RemirrorOrderedList = zod.z.lazy(function () {
1367
+ return zod.z.intersection(zod.z.object({
1368
+ type: zod.z.literal("orderedList")
1369
+ }), zod.z.object({
1370
+ content: zod.z.array(RemirrorListItem)
1371
+ }).partial());
1372
+ });
1373
+ var RemirrorListItem = zod.z.lazy(function () {
1374
+ return zod.z.intersection(zod.z.object({
1375
+ type: zod.z.literal("listItem")
1376
+ }), zod.z.object({
1377
+ content: zod.z.array(zod.z.union([RemirrorParagraph, RemirrorBulletList, RemirrorOrderedList]))
1378
+ }).partial());
1379
+ });
1380
+ var RemirrorParagraph = zod.z.intersection(zod.z.object({
1381
+ type: zod.z.literal("paragraph")
1382
+ }), zod.z.object({
1383
+ content: zod.z.array(zod.z.union([RemirrorText, RemirrorImage, RemirrorBr]))
1384
+ }).partial());
1385
+ var RemirrorJSON = zod.z.object({
1386
+ type: zod.z.literal("doc"),
1387
+ content: zod.z.array(zod.z.union([RemirrorParagraph, RemirrorHeading, RemirrorBulletList, RemirrorOrderedList]))
1388
+ });
1389
+
1390
+ function ownKeys(e, r) {
1391
+ var t = Object.keys(e);
1392
+ if (Object.getOwnPropertySymbols) {
1393
+ var o = Object.getOwnPropertySymbols(e);
1394
+ r && (o = o.filter(function (r) {
1395
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
1396
+ })), t.push.apply(t, o);
1397
+ }
1398
+ return t;
1399
+ }
1400
+ function _objectSpread2(e) {
1401
+ for (var r = 1; r < arguments.length; r++) {
1402
+ var t = null != arguments[r] ? arguments[r] : {};
1403
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
1404
+ _defineProperty(e, r, t[r]);
1405
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
1406
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1407
+ });
1408
+ }
1409
+ return e;
1410
+ }
1411
+
1412
+ function richTextToRemirror(richtext) {
1413
+ return {
1414
+ type: "doc",
1415
+ content: richtext.children.map(function (child) {
1416
+ return toRemirrorNode(child);
1417
+ })
1418
+ };
1419
+ }
1420
+ function toRemirrorNode(child) {
1421
+ switch (child.tag) {
1422
+ case "h1":
1423
+ return convertHeadingToRemirror(1, child.children);
1424
+ case "h2":
1425
+ return convertHeadingToRemirror(2, child.children);
1426
+ case "h3":
1427
+ return convertHeadingToRemirror(3, child.children);
1428
+ case "h4":
1429
+ return convertHeadingToRemirror(4, child.children);
1430
+ case "h5":
1431
+ return convertHeadingToRemirror(5, child.children);
1432
+ case "h6":
1433
+ return convertHeadingToRemirror(6, child.children);
1434
+ case "p":
1435
+ return convertParagraphToRemirror(child.children);
1436
+ case "ul":
1437
+ return convertUlToRemirror(child);
1438
+ case "ol":
1439
+ return convertOlToRemirror(child);
1440
+ case "br":
1441
+ return convertParagraphToRemirror([child]);
1442
+ default:
1443
+ {
1444
+ var _exhaustiveCheck = child;
1445
+ throw Error("Unexpected child node: " + JSON.stringify(_exhaustiveCheck));
1446
+ }
1447
+ }
1448
+ }
1449
+ function convertHeadingToRemirror(level, children) {
1450
+ return {
1451
+ type: "heading",
1452
+ attrs: {
1453
+ level: level
1454
+ },
1455
+ content: children.flatMap(convertStringOrSpanNodeToRemirror)
1456
+ };
1457
+ }
1458
+ function convertStringToRemirror(child) {
1459
+ return {
1460
+ type: "text",
1461
+ text: child
1462
+ };
1463
+ }
1464
+ function convertStringOrSpanNodeToRemirror(child) {
1465
+ if (typeof child === "string") {
1466
+ return [convertStringToRemirror(child)];
1467
+ }
1468
+ return convertSpanNodeToRemirror(child);
1469
+ }
1470
+ function convertSpanNodeToRemirror(spanNode) {
1471
+ if (spanNode.classes.length === 0 && spanNode.children.length === 1) {
1472
+ if (typeof spanNode.children[0] === "string") {
1473
+ return [convertStringToRemirror(spanNode.children[0])];
1474
+ } else {
1475
+ // TODO: replace with error logging and something more graceful?
1476
+ throw Error("Unexpected amount of children in span node: " + JSON.stringify(spanNode, null, 2));
1477
+ }
1478
+ }
1479
+ return spanNode.children.map(function (child) {
1480
+ return {
1481
+ type: "text",
1482
+ text: child,
1483
+ marks: spanNode.classes.map(function (className) {
1484
+ switch (className) {
1485
+ case "bold":
1486
+ return {
1487
+ type: "bold"
1488
+ };
1489
+ case "italic":
1490
+ return {
1491
+ type: "italic"
1492
+ };
1493
+ case "line-through":
1494
+ return {
1495
+ type: "strike"
1496
+ };
1497
+ default:
1498
+ {
1499
+ var _exhaustiveCheck = className;
1500
+ throw Error("Unexpected span class: " + _exhaustiveCheck);
1501
+ }
1502
+ }
1503
+ })
1504
+ };
1505
+ });
1506
+ }
1507
+ function convertParagraphToRemirror(children) {
1508
+ return {
1509
+ type: "paragraph",
1510
+ content: children.flatMap(function (child) {
1511
+ if (typeof child === "string") {
1512
+ return [convertStringToRemirror(child)];
1513
+ }
1514
+ switch (child.tag) {
1515
+ case "span":
1516
+ return convertSpanNodeToRemirror(child);
1517
+ case "a":
1518
+ return convertLinkNodeToRemirror(child);
1519
+ case "img":
1520
+ return [convertImageNodeToRemirror(child)];
1521
+ case "br":
1522
+ return [createRemirrorBr()];
1523
+ default:
1524
+ {
1525
+ var _exhaustiveCheck = child;
1526
+ throw Error("Unexpected paragraph child: " + JSON.stringify(_exhaustiveCheck));
1527
+ }
1528
+ }
1529
+ })
1530
+ };
1531
+ }
1532
+ function createRemirrorBr() {
1533
+ return {
1534
+ type: "hardBreak",
1535
+ marks: []
1536
+ };
1537
+ }
1538
+ function convertLinkNodeToRemirror(linkNode) {
1539
+ return linkNode.children.flatMap(convertStringOrSpanNodeToRemirror).map(function (remirrorText) {
1540
+ return _objectSpread2(_objectSpread2({}, remirrorText), {}, {
1541
+ marks: (remirrorText.marks || []).concat({
1542
+ type: "link",
1543
+ attrs: {
1544
+ href: linkNode.href,
1545
+ auto: false,
1546
+ target: null
1547
+ }
1548
+ })
1549
+ });
1550
+ });
1551
+ }
1552
+ function convertImageNodeToRemirror(imageNode) {
1553
+ return {
1554
+ type: "image",
1555
+ attrs: {
1556
+ height: imageNode.height,
1557
+ width: imageNode.width,
1558
+ src: imageNode.src // at time of writing we are not sure if src as href or data url works, also: how to keep mimeType etc?
1559
+ }
1560
+ };
1561
+ }
1562
+ function convertUlToRemirror(ulNode) {
1563
+ return {
1564
+ type: "bulletList",
1565
+ content: ulNode.children.map(convertListItemToRemirror)
1566
+ };
1567
+ }
1568
+ function convertOlToRemirror(olNode) {
1569
+ return {
1570
+ type: "orderedList",
1571
+ content: olNode.children.map(convertListItemToRemirror)
1572
+ };
1573
+ }
1574
+ function convertListItemToRemirror(liNode) {
1575
+ return {
1576
+ type: "listItem",
1577
+ content: convertListItemToRemirrorParagraph(liNode.children)
1578
+ };
1579
+ }
1580
+ function convertListItemToRemirrorParagraph(rtChildren) {
1581
+ var children = [];
1582
+ var _iterator = _createForOfIteratorHelper(rtChildren),
1583
+ _step;
1584
+ try {
1585
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1586
+ var child = _step.value;
1587
+ var lastChild = children[children.length - 1];
1588
+ if (!lastChild) {
1589
+ lastChild = {
1590
+ type: "paragraph",
1591
+ content: []
1592
+ };
1593
+ children.push(lastChild);
1594
+ }
1595
+ var lastChildContent = lastChild.content;
1596
+ if (typeof child === "string") {
1597
+ lastChildContent.push(convertStringToRemirror(child));
1598
+ } else {
1599
+ switch (child.tag) {
1600
+ case "a":
1601
+ {
1602
+ lastChildContent.push.apply(lastChildContent, _toConsumableArray(convertLinkNodeToRemirror(child)));
1603
+ break;
1604
+ }
1605
+ case "br":
1606
+ {
1607
+ children.push({
1608
+ type: "paragraph",
1609
+ content: [] // create new paragraph
1610
+ });
1611
+ break;
1612
+ }
1613
+ case "span":
1614
+ {
1615
+ lastChildContent.push.apply(lastChildContent, _toConsumableArray(convertSpanNodeToRemirror(child)));
1616
+ break;
1617
+ }
1618
+ case "ol":
1619
+ {
1620
+ children.push(convertOlToRemirror(child));
1621
+ break;
1622
+ }
1623
+ case "ul":
1624
+ {
1625
+ children.push(convertUlToRemirror(child));
1626
+ break;
1627
+ }
1628
+ default:
1629
+ {
1630
+ var _exhaustiveCheck = child;
1631
+ throw Error("Unexpected list item child: " + JSON.stringify(_exhaustiveCheck));
1632
+ }
1633
+ }
1634
+ }
1635
+ }
1636
+ } catch (err) {
1637
+ _iterator.e(err);
1638
+ } finally {
1639
+ _iterator.f();
1640
+ }
1641
+ return children;
1642
+ }
1643
+
782
1644
  var VAL_SESSION_COOKIE = core.Internal.VAL_SESSION_COOKIE;
783
1645
  var VAL_STATE_COOKIE = core.Internal.VAL_STATE_COOKIE;
784
1646
  var VAL_ENABLE_COOKIE_NAME = core.Internal.VAL_ENABLE_COOKIE_NAME;
785
1647
 
786
- exports.COMMON_LEXICAL_PROPS = COMMON_LEXICAL_PROPS;
1648
+ exports.EXT_TO_MIME_TYPES = EXT_TO_MIME_TYPES;
1649
+ exports.MIME_TYPES_TO_EXT = MIME_TYPES_TO_EXT;
1650
+ exports.RemirrorBr = RemirrorBr;
1651
+ exports.RemirrorBulletList = RemirrorBulletList;
1652
+ exports.RemirrorHeading = RemirrorHeading;
1653
+ exports.RemirrorImage = RemirrorImage;
1654
+ exports.RemirrorJSON = RemirrorJSON;
1655
+ exports.RemirrorLinkMark = RemirrorLinkMark;
1656
+ exports.RemirrorListItem = RemirrorListItem;
1657
+ exports.RemirrorOrderedList = RemirrorOrderedList;
1658
+ exports.RemirrorParagraph = RemirrorParagraph;
1659
+ exports.RemirrorText = RemirrorText;
1660
+ exports.RemirrorTextMark = RemirrorTextMark;
787
1661
  exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
788
1662
  exports.VAL_SESSION_COOKIE = VAL_SESSION_COOKIE;
789
1663
  exports.VAL_STATE_COOKIE = VAL_STATE_COOKIE;
790
1664
  exports.filenameToMimeType = filenameToMimeType;
791
- exports.fromLexicalFormat = fromLexicalFormat;
792
1665
  exports.getMimeType = getMimeType;
793
- exports.imageTypeToMimeType = imageTypeToMimeType;
794
- exports.lexicalToRichTextSource = lexicalToRichTextSource;
795
1666
  exports.mimeTypeToFileExt = mimeTypeToFileExt;
796
1667
  exports.parseRichTextSource = parseRichTextSource;
797
- exports.richTextSourceToLexical = richTextSourceToLexical;
798
- exports.toLexicalFormat = toLexicalFormat;
799
- exports.toLexicalNode = toLexicalNode;
1668
+ exports.remirrorToRichTextSource = remirrorToRichTextSource;
1669
+ exports.richTextToRemirror = richTextToRemirror;