@json-to-office/core-docx 0.17.0 → 0.17.1
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/index.js
CHANGED
|
@@ -7956,7 +7956,7 @@ function createBuilderImpl(state) {
|
|
|
7956
7956
|
}
|
|
7957
7957
|
return getThemeWithFallback(themeName);
|
|
7958
7958
|
}
|
|
7959
|
-
async function processDocumentComponents(components, preserveSet, warningsCollector, resolvedTheme, depth = 0) {
|
|
7959
|
+
async function processDocumentComponents(components, preserveSet, warningsCollector, resolvedTheme, validateEmitted, depth = 0) {
|
|
7960
7960
|
if (depth > 20) {
|
|
7961
7961
|
throw new Error(
|
|
7962
7962
|
"Maximum component nesting depth exceeded (20). Check for circular component references."
|
|
@@ -7996,6 +7996,7 @@ function createBuilderImpl(state) {
|
|
|
7996
7996
|
preserveSet,
|
|
7997
7997
|
warningsCollector,
|
|
7998
7998
|
resolvedTheme,
|
|
7999
|
+
validateEmitted,
|
|
7999
8000
|
depth + 1
|
|
8000
8001
|
);
|
|
8001
8002
|
nestedChildren = nested.standard;
|
|
@@ -8016,11 +8017,15 @@ function createBuilderImpl(state) {
|
|
|
8016
8017
|
children: nestedChildren
|
|
8017
8018
|
});
|
|
8018
8019
|
const resultComponents = Array.isArray(result) ? result : [result];
|
|
8020
|
+
if (validateEmitted) {
|
|
8021
|
+
validateEmitted(resultComponents, versionLabel);
|
|
8022
|
+
}
|
|
8019
8023
|
const processedResult = await processDocumentComponents(
|
|
8020
8024
|
resultComponents,
|
|
8021
8025
|
preserveSet,
|
|
8022
8026
|
warningsCollector,
|
|
8023
8027
|
resolvedTheme,
|
|
8028
|
+
validateEmitted,
|
|
8024
8029
|
depth + 1
|
|
8025
8030
|
);
|
|
8026
8031
|
standardOut.push(...processedResult.standard);
|
|
@@ -8050,6 +8055,7 @@ function createBuilderImpl(state) {
|
|
|
8050
8055
|
preserveSet,
|
|
8051
8056
|
warningsCollector,
|
|
8052
8057
|
resolvedTheme,
|
|
8058
|
+
validateEmitted,
|
|
8053
8059
|
depth + 1
|
|
8054
8060
|
);
|
|
8055
8061
|
standardOut.push({
|
|
@@ -8130,6 +8136,22 @@ function createBuilderImpl(state) {
|
|
|
8130
8136
|
);
|
|
8131
8137
|
}
|
|
8132
8138
|
}
|
|
8139
|
+
const validateEmitted = vOpts.enabled === false ? void 0 : (emitted, componentLabel) => {
|
|
8140
|
+
const result = validateDocument(
|
|
8141
|
+
{ ...internalDocument, children: emitted },
|
|
8142
|
+
state.components,
|
|
8143
|
+
{ allowUnknownFields: vOpts.allowUnknownFields }
|
|
8144
|
+
);
|
|
8145
|
+
if (!result.valid) {
|
|
8146
|
+
throw new ComponentValidationError2(
|
|
8147
|
+
(result.errors ?? []).map((e) => ({
|
|
8148
|
+
path: e.path ?? "",
|
|
8149
|
+
message: `custom component '${componentLabel}' emitted invalid output \u2014 ${e.message}`
|
|
8150
|
+
})),
|
|
8151
|
+
emitted
|
|
8152
|
+
);
|
|
8153
|
+
}
|
|
8154
|
+
};
|
|
8133
8155
|
const baseThemeName = internalDocument.props.theme || "minimal";
|
|
8134
8156
|
const docTheme = resolveDocumentTheme(baseThemeName);
|
|
8135
8157
|
const warnings = [];
|
|
@@ -8152,7 +8174,8 @@ function createBuilderImpl(state) {
|
|
|
8152
8174
|
mode.doc.children || [],
|
|
8153
8175
|
preserveSet,
|
|
8154
8176
|
warnings,
|
|
8155
|
-
modedTheme
|
|
8177
|
+
modedTheme,
|
|
8178
|
+
validateEmitted
|
|
8156
8179
|
);
|
|
8157
8180
|
const processedDocument = {
|
|
8158
8181
|
...mode.doc,
|