@json-to-office/core-docx 6.4.1 → 6.6.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.
- package/dist/core/imageResources.d.ts +7 -2
- package/dist/core/imageResources.d.ts.map +1 -1
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/dist/ir/compiler.d.ts.map +1 -1
- package/dist/plugin/example/index.js +17 -10
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/imageUtils.d.ts +3 -0
- package/dist/utils/imageUtils.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/ir/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/ir/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAiD3D,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,wBAAwB,CAAC;AAuC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAEL,KAAK,MAAM,EAqCZ,MAAM,SAAS,CAAC;AAiBjB,2DAA2D;AAC3D,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,2EAA2E;IAC3E,QAAQ,EAAE,SAAS,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;IACrD,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B;;;;OAIG;IACH,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAoGD,wBAAgB,eAAe,CAC7B,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE,UAAU,EAClB,QAAQ,GAAE,iBAAiB,EAAO,EAClC,MAAM,GAAE,cAA0B,EAClC,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACvC,iBAAiB,CAiHnB"}
|
|
@@ -2642,9 +2642,7 @@ async function downloadImageFromUrl(url) {
|
|
|
2642
2642
|
});
|
|
2643
2643
|
clearTimeout(timeoutId);
|
|
2644
2644
|
if (!response.ok) {
|
|
2645
|
-
throw new Error(
|
|
2646
|
-
`Failed to download image: HTTP ${response.status} ${response.statusText}`
|
|
2647
|
-
);
|
|
2645
|
+
throw new Error(`HTTP ${response.status} ${response.statusText}`);
|
|
2648
2646
|
}
|
|
2649
2647
|
const contentType = response.headers.get("content-type") || void 0;
|
|
2650
2648
|
const arrayBuffer = await response.arrayBuffer();
|
|
@@ -2656,9 +2654,9 @@ async function downloadImageFromUrl(url) {
|
|
|
2656
2654
|
"Failed to download image: Request timeout after 10 seconds"
|
|
2657
2655
|
);
|
|
2658
2656
|
}
|
|
2659
|
-
throw new Error(`Failed to download image
|
|
2657
|
+
throw new Error(`Failed to download image: ${error.message}`);
|
|
2660
2658
|
}
|
|
2661
|
-
throw new Error(
|
|
2659
|
+
throw new Error("Failed to download image: Unknown error");
|
|
2662
2660
|
}
|
|
2663
2661
|
}
|
|
2664
2662
|
function resolveImageSource(props) {
|
|
@@ -6478,6 +6476,7 @@ async function loadImageResources(components) {
|
|
|
6478
6476
|
const sources = /* @__PURE__ */ new Set();
|
|
6479
6477
|
for (const component of components) collectSources(component, sources);
|
|
6480
6478
|
const loaded = /* @__PURE__ */ new Map();
|
|
6479
|
+
const failures = /* @__PURE__ */ new Map();
|
|
6481
6480
|
await Promise.all(
|
|
6482
6481
|
[...sources].map(async (source) => {
|
|
6483
6482
|
try {
|
|
@@ -6488,11 +6487,12 @@ async function loadImageResources(components) {
|
|
|
6488
6487
|
...result.contentType ? { contentType: result.contentType } : {},
|
|
6489
6488
|
...intrinsic ? { intrinsic } : {}
|
|
6490
6489
|
});
|
|
6491
|
-
} catch {
|
|
6490
|
+
} catch (error) {
|
|
6491
|
+
failures.set(source, error);
|
|
6492
6492
|
}
|
|
6493
6493
|
})
|
|
6494
6494
|
);
|
|
6495
|
-
return loaded;
|
|
6495
|
+
return Object.assign(loaded, { failures });
|
|
6496
6496
|
}
|
|
6497
6497
|
function readIntrinsic(bytes, source) {
|
|
6498
6498
|
try {
|
|
@@ -6562,7 +6562,8 @@ function collectCellSource(content, out) {
|
|
|
6562
6562
|
// src/ir/compiler.ts
|
|
6563
6563
|
init_colorUtils();
|
|
6564
6564
|
import {
|
|
6565
|
-
FeatureRequirementCollector
|
|
6565
|
+
FeatureRequirementCollector,
|
|
6566
|
+
assetUnreadableError
|
|
6566
6567
|
} from "@json-to-office/shared/rendering";
|
|
6567
6568
|
import { capsFormatting as capsFormatting2, synthesizeFamilyName as synthesizeFamilyName2 } from "@json-to-office/shared";
|
|
6568
6569
|
import {
|
|
@@ -9548,7 +9549,7 @@ function compileChromeImage(component, scope) {
|
|
|
9548
9549
|
}
|
|
9549
9550
|
const loaded = ctx.images.get(source);
|
|
9550
9551
|
if (!loaded) {
|
|
9551
|
-
throw new Error(`Failed to load image from ${source.substring(0, 50)}`);
|
|
9552
|
+
throw unreadableImage(source, ctx) ?? new Error(`Failed to load image from ${source.substring(0, 50)}`);
|
|
9552
9553
|
}
|
|
9553
9554
|
const mediaType = detectImageType(source, loaded.contentType);
|
|
9554
9555
|
if (mediaType === "svg") ctx.features.require("svg-images", path3);
|
|
@@ -11157,6 +11158,10 @@ function visualPlacementPixels(props, canvas, reference) {
|
|
|
11157
11158
|
);
|
|
11158
11159
|
}
|
|
11159
11160
|
var UNLOWERED_IMAGE_PROPS = ["comment"];
|
|
11161
|
+
function unreadableImage(source, ctx) {
|
|
11162
|
+
const { failures } = ctx.images;
|
|
11163
|
+
return failures?.has(source) ? assetUnreadableError(source, failures.get(source)) : void 0;
|
|
11164
|
+
}
|
|
11160
11165
|
function compileImage2(component, scope) {
|
|
11161
11166
|
const { ctx, path: path3 } = scope;
|
|
11162
11167
|
const props = component.props ?? {};
|
|
@@ -11173,7 +11178,9 @@ function compileImage2(component, scope) {
|
|
|
11173
11178
|
);
|
|
11174
11179
|
}
|
|
11175
11180
|
const loaded = ctx.images.get(source);
|
|
11176
|
-
if (!loaded)
|
|
11181
|
+
if (!loaded) {
|
|
11182
|
+
throw unreadableImage(source, ctx) ?? new Error(`Failed to load image from ${source}`);
|
|
11183
|
+
}
|
|
11177
11184
|
const mediaType = detectImageType(source, loaded.contentType);
|
|
11178
11185
|
if (mediaType === "svg") ctx.features.require("svg-images", path3);
|
|
11179
11186
|
if (typeof props.alt === "string" && props.alt) {
|