@json-to-office/core-docx 5.4.0 → 6.1.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/components/highcharts.d.ts.map +1 -1
- package/dist/components/visual.d.ts.map +1 -1
- package/dist/core/desugarExternals.d.ts.map +1 -1
- package/dist/core/prerasterizeVisuals.d.ts.map +1 -1
- package/dist/index.js +68 -42
- package/dist/index.js.map +1 -1
- package/dist/plugin/example/index.js +68 -42
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/templates/themes/vermilion.docx.theme.json +2 -2
- package/dist/themes/design-system.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1038,7 +1038,7 @@ var init_vermilion_docx_theme = __esm({
|
|
|
1038
1038
|
},
|
|
1039
1039
|
actionTitle: {
|
|
1040
1040
|
type: "display",
|
|
1041
|
-
color: "
|
|
1041
|
+
color: "accent"
|
|
1042
1042
|
},
|
|
1043
1043
|
keyTakeaways: {
|
|
1044
1044
|
type: "label",
|
|
@@ -1067,7 +1067,7 @@ var init_vermilion_docx_theme = __esm({
|
|
|
1067
1067
|
},
|
|
1068
1068
|
cover: {
|
|
1069
1069
|
type: "display",
|
|
1070
|
-
color: "
|
|
1070
|
+
color: "accent",
|
|
1071
1071
|
rule: {
|
|
1072
1072
|
weightPt: 4,
|
|
1073
1073
|
color: "accent"
|
|
@@ -5433,12 +5433,15 @@ function applyThemeOverrides(theme, overrides) {
|
|
|
5433
5433
|
init_defaults();
|
|
5434
5434
|
import {
|
|
5435
5435
|
designCanvas,
|
|
5436
|
+
resolveMotif,
|
|
5436
5437
|
resolveTypeRoles,
|
|
5437
5438
|
validateDesignColors
|
|
5438
5439
|
} from "@json-to-office/shared";
|
|
5439
5440
|
function resolveDocxDesignSystem(theme) {
|
|
5440
5441
|
validateDesignColors(theme, getThemeColors(theme));
|
|
5441
|
-
|
|
5442
|
+
const motif = resolveMotif(theme.motif);
|
|
5443
|
+
if (!theme.typography && !theme.spacing)
|
|
5444
|
+
return motif === theme.motif ? theme : withMotif(theme, motif);
|
|
5442
5445
|
const canvas = designCanvas("docx", theme.page.size);
|
|
5443
5446
|
const roles = resolveTypeRoles(theme, canvas, theme.fonts.body.size ?? 11);
|
|
5444
5447
|
const styles = { ...theme.styles };
|
|
@@ -5478,7 +5481,7 @@ function resolveDocxDesignSystem(theme) {
|
|
|
5478
5481
|
const space = theme.spacing?.canvas?.[canvas];
|
|
5479
5482
|
const safe = space?.safeAreaIn;
|
|
5480
5483
|
return {
|
|
5481
|
-
...theme,
|
|
5484
|
+
...withMotif(theme, motif),
|
|
5482
5485
|
styles,
|
|
5483
5486
|
page: {
|
|
5484
5487
|
...theme.page,
|
|
@@ -5495,6 +5498,12 @@ function resolveDocxDesignSystem(theme) {
|
|
|
5495
5498
|
}
|
|
5496
5499
|
};
|
|
5497
5500
|
}
|
|
5501
|
+
function withMotif(theme, motif) {
|
|
5502
|
+
if (motif !== void 0) return { ...theme, motif };
|
|
5503
|
+
const rest = { ...theme };
|
|
5504
|
+
delete rest.motif;
|
|
5505
|
+
return rest;
|
|
5506
|
+
}
|
|
5498
5507
|
|
|
5499
5508
|
// src/core/generationContext.ts
|
|
5500
5509
|
function defaultNamedThemeLookup(themeName, customThemes, warnings) {
|
|
@@ -5861,7 +5870,7 @@ async function rasterizeVisualSlide(presentation, dpi, propsServerUrl, serviceCo
|
|
|
5861
5870
|
serviceConfig?.serverUrl,
|
|
5862
5871
|
DEFAULT_RASTERIZE_SERVER_URL
|
|
5863
5872
|
);
|
|
5864
|
-
const
|
|
5873
|
+
const body = await postJsonToService({
|
|
5865
5874
|
url: serverUrl,
|
|
5866
5875
|
path: "/rasterize",
|
|
5867
5876
|
body: {
|
|
@@ -5873,11 +5882,12 @@ async function rasterizeVisualSlide(presentation, dpi, propsServerUrl, serviceCo
|
|
|
5873
5882
|
headers: serviceConfig?.headers,
|
|
5874
5883
|
serviceLabel: "PPTX rasterization service",
|
|
5875
5884
|
onUnreachable: (url, cause) => `PPTX rasterization service is not reachable at ${url}. Configure services.pptx with a \`render\` callback or a running \`serverUrl\`.
|
|
5876
|
-
Cause: ${cause}
|
|
5885
|
+
Cause: ${cause}`,
|
|
5886
|
+
decode: (response) => response.text()
|
|
5877
5887
|
});
|
|
5878
5888
|
let result;
|
|
5879
5889
|
try {
|
|
5880
|
-
result =
|
|
5890
|
+
result = JSON.parse(body);
|
|
5881
5891
|
} catch {
|
|
5882
5892
|
throw new Error(
|
|
5883
5893
|
"PPTX rasterization service returned a non-JSON response (expected { base64DataUri, width, height })."
|
|
@@ -6065,9 +6075,9 @@ async function prerasterizeVisuals(root, serviceConfig, options = {}) {
|
|
|
6065
6075
|
DEFAULT_RASTERIZE_SERVER_URL
|
|
6066
6076
|
);
|
|
6067
6077
|
const postBatch = async (chunk, fonts) => {
|
|
6068
|
-
let
|
|
6078
|
+
let body;
|
|
6069
6079
|
try {
|
|
6070
|
-
|
|
6080
|
+
body = await postJsonToService2({
|
|
6071
6081
|
url: serverUrl,
|
|
6072
6082
|
path: "/rasterize/batch",
|
|
6073
6083
|
body: {
|
|
@@ -6080,14 +6090,21 @@ async function prerasterizeVisuals(root, serviceConfig, options = {}) {
|
|
|
6080
6090
|
},
|
|
6081
6091
|
headers: serviceConfig?.headers,
|
|
6082
6092
|
timeoutMs: BATCH_TIMEOUT_BASE_MS + BATCH_TIMEOUT_PER_SLIDE_MS * chunk.length,
|
|
6093
|
+
// The per-visual fallback below IS this call's retry, and a better
|
|
6094
|
+
// one: it degrades to smaller work instead of repeating the same
|
|
6095
|
+
// large request. Retrying here first would spend three full batch
|
|
6096
|
+
// timeouts — up to seventeen minutes on a 32-slide chunk — before
|
|
6097
|
+
// the fallback that was going to run anyway gets its turn.
|
|
6098
|
+
retries: 0,
|
|
6083
6099
|
serviceLabel: "PPTX batch rasterization service",
|
|
6084
|
-
onUnreachable: (url, cause) => `PPTX rasterization service is not reachable at ${url}. Cause: ${cause}
|
|
6100
|
+
onUnreachable: (url, cause) => `PPTX rasterization service is not reachable at ${url}. Cause: ${cause}`,
|
|
6101
|
+
decode: (response) => response.text()
|
|
6085
6102
|
});
|
|
6086
6103
|
} catch (error) {
|
|
6087
6104
|
return { applied: false, schemaRejected: isSchemaRejection(error) };
|
|
6088
6105
|
}
|
|
6089
6106
|
try {
|
|
6090
|
-
if (applyBatchResponse(chunk,
|
|
6107
|
+
if (applyBatchResponse(chunk, JSON.parse(body), map)) {
|
|
6091
6108
|
return { applied: true };
|
|
6092
6109
|
}
|
|
6093
6110
|
} catch {
|
|
@@ -6194,7 +6211,7 @@ function containsComponent(root, name) {
|
|
|
6194
6211
|
import {
|
|
6195
6212
|
clampVisualDpi as clampVisualDpi2,
|
|
6196
6213
|
DEFAULT_VISUAL_DPI as DEFAULT_VISUAL_DPI2,
|
|
6197
|
-
|
|
6214
|
+
recordChartCollected
|
|
6198
6215
|
} from "@json-to-office/shared";
|
|
6199
6216
|
import {
|
|
6200
6217
|
isNativeVisualProps as isNativeVisualProps2
|
|
@@ -6213,9 +6230,8 @@ import {
|
|
|
6213
6230
|
withChartTypography,
|
|
6214
6231
|
resolveServiceUrl as resolveServiceUrl3,
|
|
6215
6232
|
postJsonToService as postJsonToService3,
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
recordChartRetry
|
|
6233
|
+
recordChartRetry,
|
|
6234
|
+
sendChartRequest
|
|
6219
6235
|
} from "@json-to-office/shared";
|
|
6220
6236
|
var DEFAULT_EXPORT_SERVER_URL = "http://localhost:7801";
|
|
6221
6237
|
function effectiveChartServerUrl(props, servicesConfig) {
|
|
@@ -6256,14 +6272,16 @@ async function generateChart(config, servicesConfig, warnings, cache) {
|
|
|
6256
6272
|
// byte-identical to before for callers that omit it.
|
|
6257
6273
|
...config.resources ? { resources: config.resources } : {}
|
|
6258
6274
|
};
|
|
6259
|
-
return
|
|
6275
|
+
return sendChartRequest({
|
|
6260
6276
|
cache,
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6277
|
+
serverUrl,
|
|
6278
|
+
concurrency: servicesConfig?.concurrency,
|
|
6279
|
+
requestBody,
|
|
6280
|
+
send: () => postChart(serverUrl, requestBody, config, servicesConfig)
|
|
6281
|
+
});
|
|
6264
6282
|
}
|
|
6265
6283
|
async function postChart(serverUrl, requestBody, config, servicesConfig) {
|
|
6266
|
-
const
|
|
6284
|
+
const base64Data = await postJsonToService3({
|
|
6267
6285
|
url: serverUrl,
|
|
6268
6286
|
path: "/export",
|
|
6269
6287
|
body: requestBody,
|
|
@@ -6273,16 +6291,13 @@ async function postChart(serverUrl, requestBody, config, servicesConfig) {
|
|
|
6273
6291
|
onRetry: recordChartRetry,
|
|
6274
6292
|
serviceLabel: "Highcharts export server",
|
|
6275
6293
|
onUnreachable: (url, cause) => `Highcharts Export Server is not running at ${url}. Start it with: npx highcharts-export-server --enableServer true
|
|
6276
|
-
Cause: ${cause}
|
|
6294
|
+
Cause: ${cause}`,
|
|
6295
|
+
decode: (response) => response.text()
|
|
6277
6296
|
});
|
|
6278
|
-
const base64Data = await response.text();
|
|
6279
|
-
const base64DataUri = `data:image/png;base64,${base64Data}`;
|
|
6280
|
-
const width = config.options.chart.width;
|
|
6281
|
-
const height = config.options.chart.height;
|
|
6282
6297
|
return {
|
|
6283
|
-
base64DataUri
|
|
6284
|
-
width,
|
|
6285
|
-
height
|
|
6298
|
+
base64DataUri: `data:image/png;base64,${base64Data}`,
|
|
6299
|
+
width: config.options.chart.width,
|
|
6300
|
+
height: config.options.chart.height
|
|
6286
6301
|
};
|
|
6287
6302
|
}
|
|
6288
6303
|
function toChartColor(value, theme) {
|
|
@@ -6410,21 +6425,16 @@ async function desugarExternals(document, options) {
|
|
|
6410
6425
|
});
|
|
6411
6426
|
}
|
|
6412
6427
|
if (node.name === "highcharts") {
|
|
6413
|
-
|
|
6414
|
-
const chartConfig = options.services?.highcharts;
|
|
6428
|
+
recordChartCollected();
|
|
6415
6429
|
return withNodeIdentity(node, {
|
|
6416
6430
|
name: "image",
|
|
6417
|
-
props: await
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
options.chartFonts,
|
|
6425
|
-
options.warnings,
|
|
6426
|
-
chartCache
|
|
6427
|
-
)
|
|
6431
|
+
props: await renderChartToImageProps(
|
|
6432
|
+
node.props,
|
|
6433
|
+
options.theme,
|
|
6434
|
+
options.services?.highcharts,
|
|
6435
|
+
options.chartFonts,
|
|
6436
|
+
options.warnings,
|
|
6437
|
+
chartCache
|
|
6428
6438
|
)
|
|
6429
6439
|
});
|
|
6430
6440
|
}
|
|
@@ -9673,7 +9683,7 @@ function compileParagraph(component, scope) {
|
|
|
9673
9683
|
MARKDOWN_LIST_LEVELS[markdown.type]
|
|
9674
9684
|
);
|
|
9675
9685
|
}
|
|
9676
|
-
const styleId =
|
|
9686
|
+
const styleId = definedParagraphStyleId(props.themeStyle, ctx.theme);
|
|
9677
9687
|
if (styleId && !ctx.styleIds.has(styleId)) ctx.styleIds.add(styleId);
|
|
9678
9688
|
const children = compileRuns(props, text, ctx, path3);
|
|
9679
9689
|
const bookmarkName = typeof props.id === "string" ? props.id : void 0;
|
|
@@ -11018,6 +11028,22 @@ function paragraphStyleId(themeStyle) {
|
|
|
11018
11028
|
if (heading) return `JTD_HeadingText${heading[1]}`;
|
|
11019
11029
|
return themeStyle;
|
|
11020
11030
|
}
|
|
11031
|
+
function definedParagraphStyleId(themeStyle, theme) {
|
|
11032
|
+
const id = paragraphStyleId(themeStyle);
|
|
11033
|
+
if (id === void 0) return void 0;
|
|
11034
|
+
if (ALWAYS_EMITTED_PARAGRAPH_STYLE_IDS.has(id)) return id;
|
|
11035
|
+
const styles = theme.styles;
|
|
11036
|
+
const name = themeStyle;
|
|
11037
|
+
return styles && (styles[name] ?? styles[name.toLowerCase()]) ? id : void 0;
|
|
11038
|
+
}
|
|
11039
|
+
var ALWAYS_EMITTED_PARAGRAPH_STYLE_IDS = /* @__PURE__ */ new Set([
|
|
11040
|
+
"Normal",
|
|
11041
|
+
"Title",
|
|
11042
|
+
"Subtitle",
|
|
11043
|
+
"Header",
|
|
11044
|
+
"Footer",
|
|
11045
|
+
...Array.from({ length: 6 }, (_, i) => `JTD_HeadingText${i + 1}`)
|
|
11046
|
+
]);
|
|
11021
11047
|
function customOutlineLevel(themeStyle, theme) {
|
|
11022
11048
|
if (typeof themeStyle !== "string" || !themeStyle) return void 0;
|
|
11023
11049
|
if (/^heading[1-6]$/.test(themeStyle.toLowerCase())) return void 0;
|