@superdoc-dev/cli 0.2.0-next.92 → 0.2.0-next.94

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.
Files changed (2) hide show
  1. package/dist/index.js +124 -25
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -96229,7 +96229,7 @@ var init_remark_stringify_D8vxv_XI_es = __esm(() => {
96229
96229
  eol = /\r?\n|\r/g;
96230
96230
  });
96231
96231
 
96232
- // ../../packages/superdoc/dist/chunks/DocxZipper-Dd7pl56D.es.js
96232
+ // ../../packages/superdoc/dist/chunks/DocxZipper-Dt7MDO2A.es.js
96233
96233
  function getLens2(b64) {
96234
96234
  var len$1 = b64.length;
96235
96235
  if (len$1 % 4 > 0)
@@ -96401,6 +96401,10 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
96401
96401
  async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
96402
96402
  const additionalPartNames = Object.keys(updatedDocs || {});
96403
96403
  const newMediaTypes = Object.keys(media).map((name) => this.getFileExtension(name)).filter((ext) => ext && IMAGE_EXTS.has(ext));
96404
+ const extensionlessMediaOverrides = Object.entries(media).filter(([name]) => !this.getFileExtension(name)).map(([name, value]) => ({
96405
+ name,
96406
+ contentType: this.#detectImageContentType(value)
96407
+ })).filter((entry) => entry.contentType);
96404
96408
  const contentTypesPath = "[Content_Types].xml";
96405
96409
  let contentTypesXml;
96406
96410
  if (fromJson)
@@ -96423,6 +96427,13 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
96423
96427
  seenTypes.add(type);
96424
96428
  }
96425
96429
  const types3 = JSON.parse(import_lib3.xml2json(contentTypesXml, null, 2)).elements?.find((el) => el.name === "Types") || {};
96430
+ const hasPartOverride = (partName) => types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === partName);
96431
+ for (const { name, contentType } of extensionlessMediaOverrides) {
96432
+ const partName = `/${name}`;
96433
+ if (hasPartOverride(partName))
96434
+ continue;
96435
+ typesString += `<Override PartName="${partName}" ContentType="${contentType}" />`;
96436
+ }
96426
96437
  const hasComments = types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === "/word/comments.xml");
96427
96438
  const hasCommentsExtended = types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtended.xml");
96428
96439
  const hasCommentsIds = types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === "/word/commentsIds.xml");
@@ -96596,8 +96607,24 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
96596
96607
  await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
96597
96608
  return unzippedOriginalDocx;
96598
96609
  }
96610
+ #detectImageContentType(value) {
96611
+ if (value == null)
96612
+ return null;
96613
+ if (typeof value === "string" && value.startsWith("data:image/"))
96614
+ return value.match(/^data:(image\/[a-zA-Z0-9.+-]+);/i)?.[1]?.toLowerCase() || null;
96615
+ let detectedType = null;
96616
+ if (value instanceof ArrayBuffer)
96617
+ detectedType = detectImageType(new Uint8Array(value));
96618
+ else if (ArrayBuffer.isView(value))
96619
+ detectedType = detectImageType(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
96620
+ else if (typeof value === "string")
96621
+ detectedType = detectImageType(value.startsWith("data:") ? value.split(",", 2)[1] : value);
96622
+ if (!detectedType)
96623
+ return null;
96624
+ return `image/${MIME_TYPE_FOR_EXT[detectedType] || detectedType}`;
96625
+ }
96599
96626
  }, DocxZipper_default;
96600
- var init_DocxZipper_Dd7pl56D_es = __esm(() => {
96627
+ var init_DocxZipper_Dt7MDO2A_es = __esm(() => {
96601
96628
  init_rolldown_runtime_B2q5OVn9_es();
96602
96629
  init_jszip_ChlR43oI_es();
96603
96630
  init_xml_js_DLE8mr0n_es();
@@ -98231,7 +98258,10 @@ var init_DocxZipper_Dd7pl56D_es = __esm(() => {
98231
98258
  "svg",
98232
98259
  "webp"
98233
98260
  ]);
98234
- MIME_TYPE_FOR_EXT = { tif: "tiff" };
98261
+ MIME_TYPE_FOR_EXT = {
98262
+ tif: "tiff",
98263
+ jpg: "jpeg"
98264
+ };
98235
98265
  DocxZipper_default = DocxZipper;
98236
98266
  });
98237
98267
 
@@ -121884,9 +121914,9 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
121884
121914
  init_remark_gfm_z_sDF4ss_es();
121885
121915
  });
121886
121916
 
121887
- // ../../packages/superdoc/dist/chunks/src-Db-ZEAR0.es.js
121888
- var exports_src_Db_ZEAR0_es = {};
121889
- __export(exports_src_Db_ZEAR0_es, {
121917
+ // ../../packages/superdoc/dist/chunks/src-CS_uXP_L.es.js
121918
+ var exports_src_CS_uXP_L_es = {};
121919
+ __export(exports_src_CS_uXP_L_es, {
121890
121920
  zt: () => defineMark,
121891
121921
  z: () => cM,
121892
121922
  yt: () => removeAwarenessStates,
@@ -133170,6 +133200,18 @@ function editorHasDom(editor) {
133170
133200
  const opts = editor.options;
133171
133201
  return !!(opts?.document ?? opts?.mockDocument ?? (typeof document !== "undefined" ? document : null));
133172
133202
  }
133203
+ function isMismatchedTransactionError(error) {
133204
+ return (error instanceof Error ? error.message : String(error)).includes("Applying a mismatched transaction");
133205
+ }
133206
+ function insertContentAtWithRetry(editor, range, content3) {
133207
+ try {
133208
+ return Boolean(editor.commands.insertContentAt(range, content3));
133209
+ } catch (error) {
133210
+ if (!isMismatchedTransactionError(error))
133211
+ throw error;
133212
+ return Boolean(editor.commands.insertContentAt(range, content3));
133213
+ }
133214
+ }
133173
133215
  function isJsonObject(value) {
133174
133216
  return typeof value === "object" && value !== null && !Array.isArray(value);
133175
133217
  }
@@ -133673,10 +133715,10 @@ function insertStructuredWrapper(editor, input2, options) {
133673
133715
  jsonNodes.push({ type: "paragraph" });
133674
133716
  }
133675
133717
  }
133676
- const ok3 = Boolean(editor.commands.insertContentAt({
133718
+ const ok3 = insertContentAtWithRetry(editor, {
133677
133719
  from: from$12,
133678
133720
  to
133679
- }, jsonNodes));
133721
+ }, jsonNodes);
133680
133722
  if (!ok3)
133681
133723
  insertFailure = {
133682
133724
  code: "INVALID_TARGET",
@@ -133692,10 +133734,10 @@ function insertStructuredWrapper(editor, input2, options) {
133692
133734
  return false;
133693
133735
  }
133694
133736
  try {
133695
- const ok3 = Boolean(editor.commands.insertContentAt({
133737
+ const ok3 = insertContentAtWithRetry(editor, {
133696
133738
  from: from$12,
133697
133739
  to
133698
- }, value));
133740
+ }, value);
133699
133741
  if (!ok3)
133700
133742
  insertFailure = {
133701
133743
  code: "INVALID_TARGET",
@@ -180655,11 +180697,53 @@ var Node$13 = class Node$14 {
180655
180697
  });
180656
180698
  }, derivePreferredFileName = (src) => {
180657
180699
  if (typeof src !== "string" || src.length === 0)
180658
- return "image.bin";
180700
+ return "image.jpg";
180659
180701
  if (src.startsWith("data:"))
180660
180702
  return getBase64FileMeta(src).filename;
180661
- return (src.split("/").pop() ?? "").split(/[?#]/)[0] || "image.bin";
180662
- }, handleNodePath = (foundImages, editor, state) => {
180703
+ const trimmed = (src.split("/").pop() ?? "").split(/[?#]/)[0];
180704
+ if (!trimmed)
180705
+ return "image.jpg";
180706
+ if (!trimmed.includes("."))
180707
+ return `${trimmed}.jpg`;
180708
+ return trimmed;
180709
+ }, parsePositiveInt = (value) => {
180710
+ const parsed = Number.parseInt(String(value), 10);
180711
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
180712
+ }, parseSizeFromImageUrl = (src) => {
180713
+ if (typeof src !== "string" || src.length === 0 || !src.startsWith("http"))
180714
+ return null;
180715
+ try {
180716
+ const url = new URL(src);
180717
+ const width = parsePositiveInt(url.searchParams.get("width")) ?? parsePositiveInt(url.searchParams.get("w")) ?? parsePositiveInt(url.searchParams.get("imgw"));
180718
+ const height = parsePositiveInt(url.searchParams.get("height")) ?? parsePositiveInt(url.searchParams.get("h")) ?? parsePositiveInt(url.searchParams.get("imgh"));
180719
+ if (width && height)
180720
+ return {
180721
+ width,
180722
+ height
180723
+ };
180724
+ const segments = url.pathname.split("/").filter(Boolean);
180725
+ const last2 = parsePositiveInt(segments.at(-1));
180726
+ const secondLast = parsePositiveInt(segments.at(-2));
180727
+ if (secondLast && last2)
180728
+ return {
180729
+ width: secondLast,
180730
+ height: last2
180731
+ };
180732
+ const compact = segments.at(-1)?.match(/^(\d{1,5})x(\d{1,5})$/i);
180733
+ if (compact) {
180734
+ const compactWidth = parsePositiveInt(compact[1]);
180735
+ const compactHeight = parsePositiveInt(compact[2]);
180736
+ if (compactWidth && compactHeight)
180737
+ return {
180738
+ width: compactWidth,
180739
+ height: compactHeight
180740
+ };
180741
+ }
180742
+ } catch {
180743
+ return null;
180744
+ }
180745
+ return null;
180746
+ }, hasFinitePositiveSize = (size$2) => Number.isFinite(size$2?.width) && size$2.width > 0 && Number.isFinite(size$2?.height) && size$2.height > 0, handleNodePath = (foundImages, editor, state) => {
180663
180747
  const { tr } = state;
180664
180748
  const mediaStore = editor.storage.image.media ?? {};
180665
180749
  if (!editor.storage.image.media)
@@ -180675,8 +180759,10 @@ var Node$13 = class Node$14 {
180675
180759
  editor,
180676
180760
  path: mediaPath.startsWith("word/") ? mediaPath.slice(5) : mediaPath
180677
180761
  });
180762
+ const inferredSize = hasFinitePositiveSize(node3.attrs?.size) ? null : parseSizeFromImageUrl(src);
180678
180763
  tr.setNodeMarkup(pos, undefined, {
180679
180764
  ...node3.attrs,
180765
+ ...inferredSize ? { size: inferredSize } : {},
180680
180766
  src: mediaPath,
180681
180767
  rId
180682
180768
  });
@@ -199096,7 +199182,7 @@ var Node$13 = class Node$14 {
199096
199182
  trackedChanges: context.trackedChanges ?? []
199097
199183
  });
199098
199184
  }, _hoisted_1$6, _hoisted_2$2, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, _hoisted_2$1, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_HEIGHT_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, POPOVER_VERTICAL_OFFSET_PX = 15, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
199099
- var init_src_Db_ZEAR0_es = __esm(() => {
199185
+ var init_src_CS_uXP_L_es = __esm(() => {
199100
199186
  init_rolldown_runtime_B2q5OVn9_es();
199101
199187
  init_SuperConverter_6i_hCnOE_es();
199102
199188
  init_jszip_ChlR43oI_es();
@@ -199105,7 +199191,7 @@ var init_src_Db_ZEAR0_es = __esm(() => {
199105
199191
  init_unified_BRHLwnjP_es();
199106
199192
  init_remark_gfm_z_sDF4ss_es();
199107
199193
  init_remark_stringify_D8vxv_XI_es();
199108
- init_DocxZipper_Dd7pl56D_es();
199194
+ init_DocxZipper_Dt7MDO2A_es();
199109
199195
  init_vue_q66HzpoR_es();
199110
199196
  init__plugin_vue_export_helper_HmhZBO0u_es();
199111
199197
  init_eventemitter3_DGBTyUUP_es();
@@ -230833,8 +230919,8 @@ function print() { __p += __j.call(arguments, '') }
230833
230919
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
230834
230920
  };
230835
230921
  stubFalse_default = stubFalse;
230836
- freeExports$2 = typeof exports_src_Db_ZEAR0_es == "object" && exports_src_Db_ZEAR0_es && !exports_src_Db_ZEAR0_es.nodeType && exports_src_Db_ZEAR0_es;
230837
- freeModule$2 = freeExports$2 && typeof module_src_Db_ZEAR0_es == "object" && module_src_Db_ZEAR0_es && !module_src_Db_ZEAR0_es.nodeType && module_src_Db_ZEAR0_es;
230922
+ freeExports$2 = typeof exports_src_CS_uXP_L_es == "object" && exports_src_CS_uXP_L_es && !exports_src_CS_uXP_L_es.nodeType && exports_src_CS_uXP_L_es;
230923
+ freeModule$2 = freeExports$2 && typeof module_src_CS_uXP_L_es == "object" && module_src_CS_uXP_L_es && !module_src_CS_uXP_L_es.nodeType && module_src_CS_uXP_L_es;
230838
230924
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
230839
230925
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
230840
230926
  typedArrayTags = {};
@@ -230842,8 +230928,8 @@ function print() { __p += __j.call(arguments, '') }
230842
230928
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
230843
230929
  _baseIsTypedArray_default = baseIsTypedArray;
230844
230930
  _baseUnary_default = baseUnary;
230845
- freeExports$1 = typeof exports_src_Db_ZEAR0_es == "object" && exports_src_Db_ZEAR0_es && !exports_src_Db_ZEAR0_es.nodeType && exports_src_Db_ZEAR0_es;
230846
- freeModule$1 = freeExports$1 && typeof module_src_Db_ZEAR0_es == "object" && module_src_Db_ZEAR0_es && !module_src_Db_ZEAR0_es.nodeType && module_src_Db_ZEAR0_es;
230931
+ freeExports$1 = typeof exports_src_CS_uXP_L_es == "object" && exports_src_CS_uXP_L_es && !exports_src_CS_uXP_L_es.nodeType && exports_src_CS_uXP_L_es;
230932
+ freeModule$1 = freeExports$1 && typeof module_src_CS_uXP_L_es == "object" && module_src_CS_uXP_L_es && !module_src_CS_uXP_L_es.nodeType && module_src_CS_uXP_L_es;
230847
230933
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
230848
230934
  _nodeUtil_default = function() {
230849
230935
  try {
@@ -230948,8 +231034,8 @@ function print() { __p += __j.call(arguments, '') }
230948
231034
  Stack.prototype.has = _stackHas_default;
230949
231035
  Stack.prototype.set = _stackSet_default;
230950
231036
  _Stack_default = Stack;
230951
- freeExports = typeof exports_src_Db_ZEAR0_es == "object" && exports_src_Db_ZEAR0_es && !exports_src_Db_ZEAR0_es.nodeType && exports_src_Db_ZEAR0_es;
230952
- freeModule = freeExports && typeof module_src_Db_ZEAR0_es == "object" && module_src_Db_ZEAR0_es && !module_src_Db_ZEAR0_es.nodeType && module_src_Db_ZEAR0_es;
231037
+ freeExports = typeof exports_src_CS_uXP_L_es == "object" && exports_src_CS_uXP_L_es && !exports_src_CS_uXP_L_es.nodeType && exports_src_CS_uXP_L_es;
231038
+ freeModule = freeExports && typeof module_src_CS_uXP_L_es == "object" && module_src_CS_uXP_L_es && !module_src_CS_uXP_L_es.nodeType && module_src_CS_uXP_L_es;
230953
231039
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
230954
231040
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
230955
231041
  _cloneBuffer_default = cloneBuffer;
@@ -239029,13 +239115,13 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
239029
239115
 
239030
239116
  // ../../packages/superdoc/dist/super-editor.es.js
239031
239117
  var init_super_editor_es = __esm(() => {
239032
- init_src_Db_ZEAR0_es();
239118
+ init_src_CS_uXP_L_es();
239033
239119
  init_SuperConverter_6i_hCnOE_es();
239034
239120
  init_jszip_ChlR43oI_es();
239035
239121
  init_xml_js_DLE8mr0n_es();
239036
239122
  init_constants_CMPtQbp7_es();
239037
239123
  init_unified_BRHLwnjP_es();
239038
- init_DocxZipper_Dd7pl56D_es();
239124
+ init_DocxZipper_Dt7MDO2A_es();
239039
239125
  init_vue_q66HzpoR_es();
239040
239126
  init_eventemitter3_DGBTyUUP_es();
239041
239127
  init_zipper_DqXT7uTa_es();
@@ -304027,6 +304113,19 @@ function editorHasDom2(editor) {
304027
304113
  const opts = editor.options;
304028
304114
  return !!(opts?.document ?? opts?.mockDocument ?? (typeof document !== "undefined" ? document : null));
304029
304115
  }
304116
+ function isMismatchedTransactionError2(error) {
304117
+ const message = error instanceof Error ? error.message : String(error);
304118
+ return message.includes("Applying a mismatched transaction");
304119
+ }
304120
+ function insertContentAtWithRetry2(editor, range, content5) {
304121
+ try {
304122
+ return Boolean(editor.commands.insertContentAt(range, content5));
304123
+ } catch (error) {
304124
+ if (!isMismatchedTransactionError2(error))
304125
+ throw error;
304126
+ return Boolean(editor.commands.insertContentAt(range, content5));
304127
+ }
304128
+ }
304030
304129
  function isJsonObject2(value) {
304031
304130
  return typeof value === "object" && value !== null && !Array.isArray(value);
304032
304131
  }
@@ -304471,7 +304570,7 @@ function insertStructuredWrapper2(editor, input2, options) {
304471
304570
  }
304472
304571
  }
304473
304572
  }
304474
- const ok5 = Boolean(editor.commands.insertContentAt({ from: from4, to }, jsonNodes));
304573
+ const ok5 = insertContentAtWithRetry2(editor, { from: from4, to }, jsonNodes);
304475
304574
  if (!ok5) {
304476
304575
  insertFailure = {
304477
304576
  code: "INVALID_TARGET",
@@ -304488,7 +304587,7 @@ function insertStructuredWrapper2(editor, input2, options) {
304488
304587
  return false;
304489
304588
  }
304490
304589
  try {
304491
- const ok5 = Boolean(editor.commands.insertContentAt({ from: from4, to }, value));
304590
+ const ok5 = insertContentAtWithRetry2(editor, { from: from4, to }, value);
304492
304591
  if (!ok5) {
304493
304592
  insertFailure = {
304494
304593
  code: "INVALID_TARGET",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.92",
3
+ "version": "0.2.0-next.94",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -20,21 +20,21 @@
20
20
  "@types/bun": "^1.3.8",
21
21
  "@types/node": "22.19.2",
22
22
  "typescript": "^5.9.2",
23
- "@superdoc/pm-adapter": "0.0.0",
24
- "superdoc": "1.17.0",
25
23
  "@superdoc/document-api": "0.0.1",
26
- "@superdoc/super-editor": "0.0.1"
24
+ "@superdoc/super-editor": "0.0.1",
25
+ "superdoc": "1.17.0",
26
+ "@superdoc/pm-adapter": "0.0.0"
27
27
  },
28
28
  "module": "src/index.ts",
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.92",
34
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.92",
35
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.92",
36
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.92",
37
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.92"
33
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.94",
34
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.94",
35
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.94",
36
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.94",
37
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.94"
38
38
  },
39
39
  "scripts": {
40
40
  "dev": "bun run src/index.ts",