@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.cjs CHANGED
@@ -688,19 +688,39 @@ function materialize(doc, cache, changed = null) {
688
688
  mainDocumentPart: main
689
689
  });
690
690
  }
691
+ var MEDIA_TYPES = {
692
+ png: "image/png",
693
+ jpg: "image/jpeg",
694
+ jpeg: "image/jpeg",
695
+ gif: "image/gif",
696
+ bmp: "image/bmp",
697
+ tif: "image/tiff",
698
+ tiff: "image/tiff",
699
+ webp: "image/webp",
700
+ svg: "image/svg+xml",
701
+ emf: "image/x-emf",
702
+ wmf: "image/x-wmf"
703
+ };
691
704
  function withMirroredOverrides(pkg) {
692
705
  const bytes = store.contentTypesPartBytes(pkg);
693
706
  if (!bytes) return pkg;
707
+ const xml = new TextDecoder().decode(bytes.bytes);
694
708
  const declared = new Set(
695
- [...new TextDecoder().decode(bytes.bytes).matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map(
696
- (m) => m[1].toLowerCase()
697
- )
709
+ [...xml.matchAll(/PartName\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
710
+ );
711
+ const defaults = new Set(
712
+ [...xml.matchAll(/Extension\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1].toLowerCase())
698
713
  );
699
714
  let next = pkg;
700
715
  for (const name of [...pkg.parts.keys(), ...pkg.partBytes.keys()]) {
701
- const type = pkg.contentTypes.overrides.get(name.toLowerCase());
702
- if (type && !declared.has(name.toLowerCase()))
716
+ const key = name.toLowerCase();
717
+ if (declared.has(key) || key === bytes.storageKey.toLowerCase()) continue;
718
+ const extension = key.slice(key.lastIndexOf(".") + 1);
719
+ const type = pkg.contentTypes.overrides.get(key) ?? (defaults.has(extension) ? void 0 : MEDIA_TYPES[extension]);
720
+ if (type) {
703
721
  next = store.withContentTypeOverride(next, name, type, { forceOverride: true });
722
+ declared.add(key);
723
+ }
704
724
  }
705
725
  return next;
706
726
  }