@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.
@@ -1 +1 @@
1
- {"version":3,"file":"createDocumentGenerator.d.ts","sourceRoot":"","sources":["../../src/plugin/createDocumentGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAwB,MAAM,WAAW,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,KAAK,EAEV,wBAAwB,EAOxB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAejB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3C,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,oFAAoF;IACpF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,2BAA2B,CAAC;CAC1C;AAojBD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,wBAAwB,CAAC,SAAS,EAAE,CAAC,CAcvC"}
1
+ {"version":3,"file":"createDocumentGenerator.d.ts","sourceRoot":"","sources":["../../src/plugin/createDocumentGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAwB,MAAM,WAAW,CAAC;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,KAAK,EAEV,wBAAwB,EAOxB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAejB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3C,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,oFAAoF;IACpF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,2BAA2B,CAAC;CAC1C;AAgmBD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,wBAAwB,CAAC,SAAS,EAAE,CAAC,CAcvC"}
@@ -7133,7 +7133,7 @@ function createBuilderImpl(state) {
7133
7133
  }
7134
7134
  return getThemeWithFallback(themeName);
7135
7135
  }
7136
- async function processDocumentComponents(components, preserveSet, warningsCollector, resolvedTheme, depth = 0) {
7136
+ async function processDocumentComponents(components, preserveSet, warningsCollector, resolvedTheme, validateEmitted, depth = 0) {
7137
7137
  if (depth > 20) {
7138
7138
  throw new Error(
7139
7139
  "Maximum component nesting depth exceeded (20). Check for circular component references."
@@ -7173,6 +7173,7 @@ function createBuilderImpl(state) {
7173
7173
  preserveSet,
7174
7174
  warningsCollector,
7175
7175
  resolvedTheme,
7176
+ validateEmitted,
7176
7177
  depth + 1
7177
7178
  );
7178
7179
  nestedChildren = nested.standard;
@@ -7193,11 +7194,15 @@ function createBuilderImpl(state) {
7193
7194
  children: nestedChildren
7194
7195
  });
7195
7196
  const resultComponents = Array.isArray(result) ? result : [result];
7197
+ if (validateEmitted) {
7198
+ validateEmitted(resultComponents, versionLabel);
7199
+ }
7196
7200
  const processedResult = await processDocumentComponents(
7197
7201
  resultComponents,
7198
7202
  preserveSet,
7199
7203
  warningsCollector,
7200
7204
  resolvedTheme,
7205
+ validateEmitted,
7201
7206
  depth + 1
7202
7207
  );
7203
7208
  standardOut.push(...processedResult.standard);
@@ -7227,6 +7232,7 @@ function createBuilderImpl(state) {
7227
7232
  preserveSet,
7228
7233
  warningsCollector,
7229
7234
  resolvedTheme,
7235
+ validateEmitted,
7230
7236
  depth + 1
7231
7237
  );
7232
7238
  standardOut.push({
@@ -7307,6 +7313,22 @@ function createBuilderImpl(state) {
7307
7313
  );
7308
7314
  }
7309
7315
  }
7316
+ const validateEmitted = vOpts.enabled === false ? void 0 : (emitted, componentLabel) => {
7317
+ const result = validateDocument(
7318
+ { ...internalDocument, children: emitted },
7319
+ state.components,
7320
+ { allowUnknownFields: vOpts.allowUnknownFields }
7321
+ );
7322
+ if (!result.valid) {
7323
+ throw new ComponentValidationError2(
7324
+ (result.errors ?? []).map((e) => ({
7325
+ path: e.path ?? "",
7326
+ message: `custom component '${componentLabel}' emitted invalid output \u2014 ${e.message}`
7327
+ })),
7328
+ emitted
7329
+ );
7330
+ }
7331
+ };
7310
7332
  const baseThemeName = internalDocument.props.theme || "minimal";
7311
7333
  const docTheme = resolveDocumentTheme(baseThemeName);
7312
7334
  const warnings = [];
@@ -7329,7 +7351,8 @@ function createBuilderImpl(state) {
7329
7351
  mode.doc.children || [],
7330
7352
  preserveSet,
7331
7353
  warnings,
7332
- modedTheme
7354
+ modedTheme,
7355
+ validateEmitted
7333
7356
  );
7334
7357
  const processedDocument = {
7335
7358
  ...mode.doc,