@json-to-office/core-docx 5.3.0 → 5.4.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 +15 -2
- package/dist/components/highcharts.d.ts.map +1 -1
- package/dist/components/visual.d.ts.map +1 -1
- package/dist/core/desugarExternals.d.ts +10 -5
- package/dist/core/desugarExternals.d.ts.map +1 -1
- package/dist/core/flattenVisuals.d.ts.map +1 -1
- package/dist/core/prerasterizeVisuals.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -96
- package/dist/index.js.map +1 -1
- package/dist/plugin/example/index.js +62 -94
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/utils/promiseLimiter.d.ts +0 -7
- package/dist/utils/promiseLimiter.d.ts.map +0 -1
- package/dist/utils/serviceClient.d.ts +0 -45
- package/dist/utils/serviceClient.d.ts.map +0 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { ThemeConfig } from '../styles';
|
|
10
10
|
import type { HighchartsProps } from '@json-to-office/shared-docx';
|
|
11
11
|
import type { GenerationWarning } from '@json-to-office/shared';
|
|
12
|
-
import { type HighchartsServiceConfig, type RasterizeFontFace } from '@json-to-office/shared';
|
|
12
|
+
import { type ChartRenderCache, type HighchartsServiceConfig, type RasterizeFontFace } from '@json-to-office/shared';
|
|
13
13
|
export type { HighchartsProps } from '@json-to-office/shared-docx';
|
|
14
14
|
/**
|
|
15
15
|
* Chart generation result
|
|
@@ -19,6 +19,19 @@ export interface ChartGenerationResult {
|
|
|
19
19
|
width: number;
|
|
20
20
|
height: number;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Per-document memo of chart renders. A report that repeats a figure — the
|
|
24
|
+
* same series in a summary and again in its section — pays for it once.
|
|
25
|
+
*/
|
|
26
|
+
export type ChartCache = ChartRenderCache<ChartGenerationResult>;
|
|
27
|
+
/**
|
|
28
|
+
* The export server this chart will actually be posted to.
|
|
29
|
+
*
|
|
30
|
+
* Exported because the concurrency gate is keyed by it: `desugarExternals`
|
|
31
|
+
* has to know which server a chart is bound for before it lets the request
|
|
32
|
+
* through, and resolving that in two places is how the two would drift.
|
|
33
|
+
*/
|
|
34
|
+
export declare function effectiveChartServerUrl(props: HighchartsProps, servicesConfig: HighchartsServiceConfig | undefined): string;
|
|
22
35
|
/**
|
|
23
36
|
* Generate chart using Highcharts Export Server
|
|
24
37
|
*/
|
|
@@ -36,5 +49,5 @@ export declare function assertExportServerAllowed(serverUrl: string, servicesCon
|
|
|
36
49
|
* rather than merging with it — stating one and inheriting the other would
|
|
37
50
|
* distort the chart.
|
|
38
51
|
*/
|
|
39
|
-
export declare function renderChartToImageProps(props: HighchartsProps, theme: ThemeConfig, servicesConfig?: HighchartsServiceConfig, chartFonts?: readonly RasterizeFontFace[], warnings?: GenerationWarning[]): Promise<Record<string, unknown>>;
|
|
52
|
+
export declare function renderChartToImageProps(props: HighchartsProps, theme: ThemeConfig, servicesConfig?: HighchartsServiceConfig, chartFonts?: readonly RasterizeFontFace[], warnings?: GenerationWarning[], cache?: ChartCache): Promise<Record<string, unknown>>;
|
|
40
53
|
//# sourceMappingURL=highcharts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAMxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAcL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;AAIjE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,eAAe,EACtB,cAAc,EAAE,uBAAuB,GAAG,SAAS,GAClD,MAAM,CAMR;AAED;;GAEG;AACH;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,uBAAuB,GAAG,SAAS,EACnD,QAAQ,EAAE,iBAAiB,EAAE,GAAG,SAAS,GACxC,IAAI,CAkBN;AAwOD;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,WAAW,EAClB,cAAc,CAAC,EAAE,uBAAuB,EACxC,UAAU,CAAC,EAAE,SAAS,iBAAiB,EAAE,EACzC,QAAQ,CAAC,EAAE,iBAAiB,EAAE,EAC9B,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAoBlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../src/components/visual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../src/components/visual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,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X,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAIR;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,iBAAiB,EACxB,aAAa,EAAE,iBAAiB,GAAG,SAAS,GAC3C,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,aAAa,EAAE,iBAAiB,GAAG,SAAS,EAC5C,OAAO,EAAE,MAAM,GAAG,SAAS;AAC3B;;;;GAIG;AACH,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,GACnC,OAAO,CAAC,mBAAmB,CAAC,CAuD9B"}
|
|
@@ -29,11 +29,16 @@ export interface DesugarExternalsOptions {
|
|
|
29
29
|
/**
|
|
30
30
|
* Replace every `visual` and `highcharts` in `document` with its image.
|
|
31
31
|
*
|
|
32
|
-
* Visuals are rasterized in one batch first:
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
32
|
+
* Visuals are rasterized in one batch first: without it each visual would cost
|
|
33
|
+
* its own service round trip and its own LibreOffice launch — about
|
|
34
|
+
* twenty-five of each for the bundled templates. The batch is only an
|
|
35
|
+
* accelerator, though: anything it misses, or a batch that fails outright,
|
|
36
|
+
* falls back to rasterizing that visual on its own.
|
|
37
|
+
*
|
|
38
|
+
* The walk resolves sibling components together rather than one at a time, so
|
|
39
|
+
* charts are not paced by the document's shape and have to be paced
|
|
40
|
+
* deliberately: each one waits for a slot in its export server's gate, and a
|
|
41
|
+
* chart identical to one already rendered here reuses that render.
|
|
37
42
|
*/
|
|
38
43
|
export declare function desugarExternals<T>(document: T, options: DesugarExternalsOptions): Promise<T>;
|
|
39
44
|
//# sourceMappingURL=desugarExternals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desugarExternals.d.ts","sourceRoot":"","sources":["../../src/core/desugarExternals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"desugarExternals.d.ts","sourceRoot":"","sources":["../../src/core/desugarExternals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAgB7C,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC3C,2EAA2E;IAC3E,UAAU,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC1C,kEAAkE;IAClE,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,CAAC,CAAC,CA8DZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenVisuals.d.ts","sourceRoot":"","sources":["../../src/core/flattenVisuals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"flattenVisuals.d.ts","sourceRoot":"","sources":["../../src/core/flattenVisuals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAgBhC,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,SAAS,EAAE,cAAc,CAAC;IAC1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACtC;AAUD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,CAAC,GAAG,OAAO,EAC9C,GAAG,EAAE,CAAC,EACN,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,CAAC,CAAC,CAyDZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerasterizeVisuals.d.ts","sourceRoot":"","sources":["../../src/core/prerasterizeVisuals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EAEtB,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"prerasterizeVisuals.d.ts","sourceRoot":"","sources":["../../src/core/prerasterizeVisuals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EAEtB,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,EAIvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAgBrC,MAAM,WAAW,mBAAmB;IAClC,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACtC;AAED,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;CAChB;AAQD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,CAE1D;AAED,wBAAgB,uBAAuB,IAAI,IAAI,CAI9C;AAkBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,iBAAiB,EAAE,CAiCrE;AA6ED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,OAAO,EACb,aAAa,EAAE,iBAAiB,GAAG,SAAS,EAC5C,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC,CAiOrD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { docxRendererIds, docxRendererStatuses, isDocxRendererId, } from './rend
|
|
|
6
6
|
export { UncompiledComponentError } from './core/generateFromIr';
|
|
7
7
|
export { flattenVisuals, type FlattenVisualsOptions, } from './core/flattenVisuals';
|
|
8
8
|
export { getVisualPrepassStats, resetVisualPrepassStats, type VisualPrepassStats, } from './core/prerasterizeVisuals';
|
|
9
|
+
export { getChartRequestStats, resetChartRequestStats, type ChartRequestStats, } from '@json-to-office/shared';
|
|
9
10
|
export { isReportComponent, isSectionComponent, isHeadingComponent, isParagraphComponent, isColumnsComponent, isImageComponent, isStatisticComponent, isTableComponent, isListComponent, isHighchartsComponent, isVisualComponent, } from './types/index';
|
|
10
11
|
export type { ReportComponentDefinition, ReportComponentDefinitionFor, ImageContent, StatisticContent, TableData, SectionProperties, ColumnSettings, PageSizeOptions, PageMarginOptions, PageNumberOptions, PageBorderOptions, RenderContext, } from './types/index';
|
|
11
12
|
export * from './utils/formatters';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAID,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,IAAI,qBAAqB,EAC1C,KAAK,oBAAoB,GAC1B,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,kBAAkB,GACxB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAID,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,IAAI,qBAAqB,EAC1C,KAAK,oBAAoB,GAC1B,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB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,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,aAAa,IAAI,sBAAsB,EAC5C,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAGpB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5508,7 +5508,10 @@ import {
|
|
|
5508
5508
|
import {
|
|
5509
5509
|
clampVisualDpi,
|
|
5510
5510
|
DEFAULT_VISUAL_DPI,
|
|
5511
|
-
MAX_RASTERIZE_BATCH_SLIDES
|
|
5511
|
+
MAX_RASTERIZE_BATCH_SLIDES,
|
|
5512
|
+
createLimiter,
|
|
5513
|
+
resolveServiceUrl as resolveServiceUrl2,
|
|
5514
|
+
postJsonToService as postJsonToService2
|
|
5512
5515
|
} from "@json-to-office/shared";
|
|
5513
5516
|
import {
|
|
5514
5517
|
isNativeVisualProps
|
|
@@ -5529,54 +5532,8 @@ function hasNodeBuiltins() {
|
|
|
5529
5532
|
}
|
|
5530
5533
|
}
|
|
5531
5534
|
|
|
5532
|
-
// src/utils/serviceClient.ts
|
|
5533
|
-
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
5534
|
-
function resolveServiceUrl(propsUrl, servicesUrl, defaultUrl) {
|
|
5535
|
-
const raw = (propsUrl || servicesUrl || defaultUrl).trim();
|
|
5536
|
-
const withScheme = /^https?:\/\//i.test(raw) ? raw : `http://${raw}`;
|
|
5537
|
-
return withScheme.replace(/\/+$/, "");
|
|
5538
|
-
}
|
|
5539
|
-
var SERVICE_UNAVAILABLE_CODE = "SERVICE_UNAVAILABLE";
|
|
5540
|
-
function serviceUnavailable(message) {
|
|
5541
|
-
return Object.assign(new Error(message), { code: SERVICE_UNAVAILABLE_CODE });
|
|
5542
|
-
}
|
|
5543
|
-
async function postJsonToService(opts) {
|
|
5544
|
-
const resolvedHeaders = typeof opts.headers === "function" ? await opts.headers(opts.body) : opts.headers;
|
|
5545
|
-
const headers = {
|
|
5546
|
-
"Content-Type": "application/json",
|
|
5547
|
-
...resolvedHeaders
|
|
5548
|
-
};
|
|
5549
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
5550
|
-
const controller = new AbortController();
|
|
5551
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
5552
|
-
let response;
|
|
5553
|
-
try {
|
|
5554
|
-
response = await fetch(`${opts.url}${opts.path}`, {
|
|
5555
|
-
method: "POST",
|
|
5556
|
-
headers,
|
|
5557
|
-
body: JSON.stringify(opts.body),
|
|
5558
|
-
signal: controller.signal
|
|
5559
|
-
});
|
|
5560
|
-
} catch (error) {
|
|
5561
|
-
if (error?.name === "AbortError") {
|
|
5562
|
-
throw serviceUnavailable(
|
|
5563
|
-
`${opts.serviceLabel} timed out after ${timeoutMs}ms at ${opts.url}.`
|
|
5564
|
-
);
|
|
5565
|
-
}
|
|
5566
|
-
const cause = error instanceof Error ? error.message : String(error);
|
|
5567
|
-
throw serviceUnavailable(opts.onUnreachable(opts.url, cause));
|
|
5568
|
-
} finally {
|
|
5569
|
-
clearTimeout(timer);
|
|
5570
|
-
}
|
|
5571
|
-
if (!response.ok) {
|
|
5572
|
-
throw new Error(
|
|
5573
|
-
`${opts.serviceLabel} returned ${response.status}: ${response.statusText}`
|
|
5574
|
-
);
|
|
5575
|
-
}
|
|
5576
|
-
return response;
|
|
5577
|
-
}
|
|
5578
|
-
|
|
5579
5535
|
// src/components/visual.ts
|
|
5536
|
+
import { resolveServiceUrl, postJsonToService } from "@json-to-office/shared";
|
|
5580
5537
|
var DEFAULT_RASTERIZE_SERVER_URL = "http://localhost:7802";
|
|
5581
5538
|
var PIXELS_PER_INCH = 96;
|
|
5582
5539
|
function buildVisualPresentation(props) {
|
|
@@ -5678,26 +5635,6 @@ Cause: ${cause}`
|
|
|
5678
5635
|
return result;
|
|
5679
5636
|
}
|
|
5680
5637
|
|
|
5681
|
-
// src/utils/promiseLimiter.ts
|
|
5682
|
-
function createLimiter(max) {
|
|
5683
|
-
let active = 0;
|
|
5684
|
-
const queue = [];
|
|
5685
|
-
const release = () => {
|
|
5686
|
-
active--;
|
|
5687
|
-
queue.shift()?.();
|
|
5688
|
-
};
|
|
5689
|
-
return async function limit(fn) {
|
|
5690
|
-
while (active >= max)
|
|
5691
|
-
await new Promise((resolve4) => queue.push(resolve4));
|
|
5692
|
-
active++;
|
|
5693
|
-
try {
|
|
5694
|
-
return await fn();
|
|
5695
|
-
} finally {
|
|
5696
|
-
release();
|
|
5697
|
-
}
|
|
5698
|
-
};
|
|
5699
|
-
}
|
|
5700
|
-
|
|
5701
5638
|
// src/core/prerasterizeVisuals.ts
|
|
5702
5639
|
var DEFAULT_FALLBACK_CONCURRENCY = 4;
|
|
5703
5640
|
var BATCH_TIMEOUT_BASE_MS = 3e4;
|
|
@@ -5874,7 +5811,7 @@ async function prerasterizeVisuals(root, serviceConfig, options = {}) {
|
|
|
5874
5811
|
await rasterizeIndividually(unique);
|
|
5875
5812
|
return map;
|
|
5876
5813
|
}
|
|
5877
|
-
const serverUrl =
|
|
5814
|
+
const serverUrl = resolveServiceUrl2(
|
|
5878
5815
|
void 0,
|
|
5879
5816
|
serviceConfig?.serverUrl,
|
|
5880
5817
|
DEFAULT_RASTERIZE_SERVER_URL
|
|
@@ -5882,7 +5819,7 @@ async function prerasterizeVisuals(root, serviceConfig, options = {}) {
|
|
|
5882
5819
|
const postBatch = async (chunk, fonts) => {
|
|
5883
5820
|
let response;
|
|
5884
5821
|
try {
|
|
5885
|
-
response = await
|
|
5822
|
+
response = await postJsonToService2({
|
|
5886
5823
|
url: serverUrl,
|
|
5887
5824
|
path: "/rasterize/batch",
|
|
5888
5825
|
body: {
|
|
@@ -6008,7 +5945,8 @@ function containsComponent(root, name) {
|
|
|
6008
5945
|
// src/core/desugarExternals.ts
|
|
6009
5946
|
import {
|
|
6010
5947
|
clampVisualDpi as clampVisualDpi2,
|
|
6011
|
-
DEFAULT_VISUAL_DPI as DEFAULT_VISUAL_DPI2
|
|
5948
|
+
DEFAULT_VISUAL_DPI as DEFAULT_VISUAL_DPI2,
|
|
5949
|
+
limitChartRequest
|
|
6012
5950
|
} from "@json-to-office/shared";
|
|
6013
5951
|
import {
|
|
6014
5952
|
isNativeVisualProps as isNativeVisualProps2
|
|
@@ -6024,30 +5962,42 @@ import {
|
|
|
6024
5962
|
chartPointsPerPixel,
|
|
6025
5963
|
POINTS_PER_PIXEL_96DPI,
|
|
6026
5964
|
withChartFontFaceCss,
|
|
6027
|
-
withChartTypography
|
|
5965
|
+
withChartTypography,
|
|
5966
|
+
resolveServiceUrl as resolveServiceUrl3,
|
|
5967
|
+
postJsonToService as postJsonToService3,
|
|
5968
|
+
chartRequestKey,
|
|
5969
|
+
dedupeChartRequest,
|
|
5970
|
+
recordChartRetry
|
|
6028
5971
|
} from "@json-to-office/shared";
|
|
6029
5972
|
var DEFAULT_EXPORT_SERVER_URL = "http://localhost:7801";
|
|
5973
|
+
function effectiveChartServerUrl(props, servicesConfig) {
|
|
5974
|
+
return resolveServiceUrl3(
|
|
5975
|
+
props.serverUrl,
|
|
5976
|
+
servicesConfig?.serverUrl,
|
|
5977
|
+
DEFAULT_EXPORT_SERVER_URL
|
|
5978
|
+
);
|
|
5979
|
+
}
|
|
6030
5980
|
function assertExportServerAllowed(serverUrl, servicesConfig, warnings) {
|
|
6031
5981
|
const notice = remoteExportNotice(serverUrl, servicesConfig?.allowRemote);
|
|
6032
|
-
if (notice)
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
5982
|
+
if (!notice || !warnings) return;
|
|
5983
|
+
const alreadySaid = warnings.some(
|
|
5984
|
+
(warning) => warning.context?.code === REMOTE_EXPORT_WARNING && warning.context?.serverUrl === serverUrl
|
|
5985
|
+
);
|
|
5986
|
+
if (alreadySaid) return;
|
|
5987
|
+
warnings.push({
|
|
5988
|
+
component: "highcharts",
|
|
5989
|
+
severity: "warning",
|
|
5990
|
+
message: notice,
|
|
5991
|
+
context: { code: REMOTE_EXPORT_WARNING, serverUrl }
|
|
5992
|
+
});
|
|
6039
5993
|
}
|
|
6040
|
-
async function generateChart(config, servicesConfig, warnings) {
|
|
5994
|
+
async function generateChart(config, servicesConfig, warnings, cache) {
|
|
6041
5995
|
if (!isNodeEnvironment()) {
|
|
6042
5996
|
throw new Error(
|
|
6043
5997
|
"Highcharts export server requires a Node.js environment. Chart generation is not available in browser environments."
|
|
6044
5998
|
);
|
|
6045
5999
|
}
|
|
6046
|
-
const serverUrl =
|
|
6047
|
-
config.serverUrl,
|
|
6048
|
-
servicesConfig?.serverUrl,
|
|
6049
|
-
DEFAULT_EXPORT_SERVER_URL
|
|
6050
|
-
);
|
|
6000
|
+
const serverUrl = effectiveChartServerUrl(config, servicesConfig);
|
|
6051
6001
|
assertExportServerAllowed(serverUrl, servicesConfig, warnings);
|
|
6052
6002
|
const requestBody = {
|
|
6053
6003
|
infile: config.options,
|
|
@@ -6058,11 +6008,21 @@ async function generateChart(config, servicesConfig, warnings) {
|
|
|
6058
6008
|
// byte-identical to before for callers that omit it.
|
|
6059
6009
|
...config.resources ? { resources: config.resources } : {}
|
|
6060
6010
|
};
|
|
6061
|
-
|
|
6011
|
+
return dedupeChartRequest(
|
|
6012
|
+
cache,
|
|
6013
|
+
chartRequestKey(serverUrl, requestBody),
|
|
6014
|
+
() => postChart(serverUrl, requestBody, config, servicesConfig)
|
|
6015
|
+
);
|
|
6016
|
+
}
|
|
6017
|
+
async function postChart(serverUrl, requestBody, config, servicesConfig) {
|
|
6018
|
+
const response = await postJsonToService3({
|
|
6062
6019
|
url: serverUrl,
|
|
6063
6020
|
path: "/export",
|
|
6064
6021
|
body: requestBody,
|
|
6065
6022
|
headers: servicesConfig?.headers,
|
|
6023
|
+
timeoutMs: servicesConfig?.timeoutMs,
|
|
6024
|
+
retries: servicesConfig?.retries,
|
|
6025
|
+
onRetry: recordChartRetry,
|
|
6066
6026
|
serviceLabel: "Highcharts export server",
|
|
6067
6027
|
onUnreachable: (url, cause) => `Highcharts Export Server is not running at ${url}. Start it with: npx highcharts-export-server --enableServer true
|
|
6068
6028
|
Cause: ${cause}`
|
|
@@ -6161,13 +6121,13 @@ function withChartFontFaces(config, theme, faces) {
|
|
|
6161
6121
|
theme.fonts.heading.family
|
|
6162
6122
|
]);
|
|
6163
6123
|
}
|
|
6164
|
-
async function renderChartToImageProps(props, theme, servicesConfig, chartFonts, warnings) {
|
|
6124
|
+
async function renderChartToImageProps(props, theme, servicesConfig, chartFonts, warnings, cache) {
|
|
6165
6125
|
const config = withChartFontFaces(
|
|
6166
6126
|
withThemeTypography(withThemeColors(props, theme), theme),
|
|
6167
6127
|
theme,
|
|
6168
6128
|
chartFonts
|
|
6169
6129
|
);
|
|
6170
|
-
const chart = await generateChart(config, servicesConfig, warnings);
|
|
6130
|
+
const chart = await generateChart(config, servicesConfig, warnings, cache);
|
|
6171
6131
|
const hasConfigDimensions = config.width !== void 0 || config.height !== void 0;
|
|
6172
6132
|
return {
|
|
6173
6133
|
base64: chart.base64DataUri,
|
|
@@ -6187,6 +6147,7 @@ async function desugarExternals(document, options) {
|
|
|
6187
6147
|
...options.visualFonts ? { fonts: options.visualFonts } : {}
|
|
6188
6148
|
}
|
|
6189
6149
|
).catch(() => /* @__PURE__ */ new Map());
|
|
6150
|
+
const chartCache = /* @__PURE__ */ new Map();
|
|
6190
6151
|
return transformComponents(document, async (node) => {
|
|
6191
6152
|
if (node.enabled === false) return void 0;
|
|
6192
6153
|
if (node.name === "visual") {
|
|
@@ -6201,14 +6162,21 @@ async function desugarExternals(document, options) {
|
|
|
6201
6162
|
});
|
|
6202
6163
|
}
|
|
6203
6164
|
if (node.name === "highcharts") {
|
|
6165
|
+
const props = node.props;
|
|
6166
|
+
const chartConfig = options.services?.highcharts;
|
|
6204
6167
|
return withNodeIdentity(node, {
|
|
6205
6168
|
name: "image",
|
|
6206
|
-
props: await
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6169
|
+
props: await limitChartRequest(
|
|
6170
|
+
effectiveChartServerUrl(props, chartConfig),
|
|
6171
|
+
chartConfig?.concurrency,
|
|
6172
|
+
() => renderChartToImageProps(
|
|
6173
|
+
props,
|
|
6174
|
+
options.theme,
|
|
6175
|
+
chartConfig,
|
|
6176
|
+
options.chartFonts,
|
|
6177
|
+
options.warnings,
|
|
6178
|
+
chartCache
|
|
6179
|
+
)
|
|
6212
6180
|
)
|
|
6213
6181
|
});
|
|
6214
6182
|
}
|
|
@@ -14307,7 +14275,8 @@ var DocumentGenerator = {
|
|
|
14307
14275
|
// src/core/flattenVisuals.ts
|
|
14308
14276
|
import {
|
|
14309
14277
|
clampVisualDpi as clampVisualDpi3,
|
|
14310
|
-
DEFAULT_VISUAL_DPI as DEFAULT_VISUAL_DPI3
|
|
14278
|
+
DEFAULT_VISUAL_DPI as DEFAULT_VISUAL_DPI3,
|
|
14279
|
+
createLimiter as createLimiter2
|
|
14311
14280
|
} from "@json-to-office/shared";
|
|
14312
14281
|
import {
|
|
14313
14282
|
isNativeVisualProps as isNativeVisualProps5
|
|
@@ -14349,7 +14318,7 @@ async function flattenVisuals(doc, options) {
|
|
|
14349
14318
|
dpi: options.dpi,
|
|
14350
14319
|
baseDir: options.baseDir,
|
|
14351
14320
|
fonts: options.fonts,
|
|
14352
|
-
limit:
|
|
14321
|
+
limit: createLimiter2(
|
|
14353
14322
|
Math.max(1, options.concurrency ?? DEFAULT_CONCURRENCY)
|
|
14354
14323
|
)
|
|
14355
14324
|
};
|
|
@@ -14381,6 +14350,12 @@ async function rasterizeVisual(obj, ctx) {
|
|
|
14381
14350
|
});
|
|
14382
14351
|
}
|
|
14383
14352
|
|
|
14353
|
+
// src/index.ts
|
|
14354
|
+
import {
|
|
14355
|
+
getChartRequestStats,
|
|
14356
|
+
resetChartRequestStats
|
|
14357
|
+
} from "@json-to-office/shared";
|
|
14358
|
+
|
|
14384
14359
|
// src/quality/preflight.ts
|
|
14385
14360
|
import {
|
|
14386
14361
|
assertValidQualityPolicy,
|
|
@@ -17766,6 +17741,7 @@ export {
|
|
|
17766
17741
|
generateComponentSchemas,
|
|
17767
17742
|
generatePluginDocumentSchema,
|
|
17768
17743
|
generateWarningsDocument,
|
|
17744
|
+
getChartRequestStats,
|
|
17769
17745
|
getCoreVersion,
|
|
17770
17746
|
getExample,
|
|
17771
17747
|
getExampleNames,
|
|
@@ -17792,6 +17768,7 @@ export {
|
|
|
17792
17768
|
mergeSchemas,
|
|
17793
17769
|
minimalTheme,
|
|
17794
17770
|
prepareDocxQualityDocument,
|
|
17771
|
+
resetChartRequestStats,
|
|
17795
17772
|
resetVisualPrepassStats,
|
|
17796
17773
|
resolveDocxQualityProfile,
|
|
17797
17774
|
runExample,
|