@arbidocs/coedit 0.4.99 → 0.4.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -666,19 +666,39 @@ function materialize(doc, cache, changed = null) {
666
666
  mainDocumentPart: main
667
667
  });
668
668
  }
669
+ var MEDIA_TYPES = {
670
+ png: "image/png",
671
+ jpg: "image/jpeg",
672
+ jpeg: "image/jpeg",
673
+ gif: "image/gif",
674
+ bmp: "image/bmp",
675
+ tif: "image/tiff",
676
+ tiff: "image/tiff",
677
+ webp: "image/webp",
678
+ svg: "image/svg+xml",
679
+ emf: "image/x-emf",
680
+ wmf: "image/x-wmf"
681
+ };
669
682
  function withMirroredOverrides(pkg) {
670
683
  const bytes = contentTypesPartBytes(pkg);
671
684
  if (!bytes) return pkg;
685
+ const xml = new TextDecoder().decode(bytes.bytes);
672
686
  const declared = new Set(
673
- [...new TextDecoder().decode(bytes.bytes).matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map(
674
- (m) => m[1].toLowerCase()
675
- )
687
+ [...xml.matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
688
+ );
689
+ const defaults = new Set(
690
+ [...xml.matchAll(/Extension\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
676
691
  );
677
692
  let next = pkg;
678
693
  for (const name of [...pkg.parts.keys(), ...pkg.partBytes.keys()]) {
679
- const type = pkg.contentTypes.overrides.get(name.toLowerCase());
680
- if (type && !declared.has(name.toLowerCase()))
694
+ const key = name.toLowerCase();
695
+ if (declared.has(key) || key === bytes.storageKey.toLowerCase()) continue;
696
+ const extension = key.slice(key.lastIndexOf(".") + 1);
697
+ const type = pkg.contentTypes.overrides.get(key) ?? (defaults.has(extension) ? void 0 : MEDIA_TYPES[extension]);
698
+ if (type) {
681
699
  next = withContentTypeOverride(next, name, type, { forceOverride: true });
700
+ declared.add(key);
701
+ }
682
702
  }
683
703
  return next;
684
704
  }