@json-to-office/core-docx 0.29.0 → 0.30.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.
@@ -1 +1 @@
1
- {"version":3,"file":"createDocumentGenerator.d.ts","sourceRoot":"","sources":["../../src/plugin/createDocumentGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAK7C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,KAAK,EAEV,wBAAwB,EAOxB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAmBjB;;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;IACzC,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAyoBD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,wBAAwB,CAAC,SAAS,EAAE,CAAC,CAiBvC"}
1
+ {"version":3,"file":"createDocumentGenerator.d.ts","sourceRoot":"","sources":["../../src/plugin/createDocumentGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAK7C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,KAAK,EAEV,wBAAwB,EAQxB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAmBjB;;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;IACzC,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA8sBD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,wBAAwB,CAAC,SAAS,EAAE,CAAC,CAiBvC"}
@@ -8284,70 +8284,104 @@ function createBuilderImpl(state) {
8284
8284
  }
8285
8285
  return new Set(list);
8286
8286
  }
8287
- async function generate(document, options) {
8288
- try {
8289
- const preserveSet = resolvePreserveSet(options);
8290
- const rootIn = document;
8291
- const internalDocument = rootIn.props === void 0 ? { ...rootIn, props: {} } : rootIn;
8292
- const vOpts = {
8293
- ...state.validation,
8294
- ...options?.validation
8295
- };
8296
- if (vOpts.enabled !== false) {
8297
- const result = validateDocument(
8298
- internalDocument,
8299
- state.components,
8300
- { allowUnknownFields: vOpts.allowUnknownFields }
8287
+ async function expandDocument(document, options) {
8288
+ const preserveSet = resolvePreserveSet(options);
8289
+ const rootIn = document;
8290
+ const internalDocument = rootIn.props === void 0 ? { ...rootIn, props: {} } : rootIn;
8291
+ const vOpts = {
8292
+ ...state.validation,
8293
+ ...options?.validation
8294
+ };
8295
+ if (vOpts.enabled !== false) {
8296
+ const result = validateDocument(
8297
+ internalDocument,
8298
+ state.components,
8299
+ { allowUnknownFields: vOpts.allowUnknownFields }
8300
+ );
8301
+ if (!result.valid) {
8302
+ throw new ComponentValidationError2(
8303
+ (result.errors ?? []).map((e) => ({
8304
+ path: e.path ?? "",
8305
+ message: e.message
8306
+ })),
8307
+ internalDocument
8301
8308
  );
8302
- if (!result.valid) {
8303
- throw new ComponentValidationError2(
8304
- (result.errors ?? []).map((e) => ({
8305
- path: e.path ?? "",
8306
- message: e.message
8307
- })),
8308
- internalDocument
8309
- );
8310
- }
8311
8309
  }
8312
- const validateEmitted = vOpts.enabled === false ? void 0 : (emitted, componentLabel) => {
8313
- const result = validateDocument(
8314
- { ...internalDocument, children: emitted },
8315
- state.components,
8316
- { allowUnknownFields: vOpts.allowUnknownFields }
8310
+ }
8311
+ const validateEmitted = vOpts.enabled === false ? void 0 : (emitted, componentLabel) => {
8312
+ const result = validateDocument(
8313
+ { ...internalDocument, children: emitted },
8314
+ state.components,
8315
+ { allowUnknownFields: vOpts.allowUnknownFields }
8316
+ );
8317
+ if (!result.valid) {
8318
+ throw new ComponentValidationError2(
8319
+ (result.errors ?? []).map((e) => ({
8320
+ path: e.path ?? "",
8321
+ message: `custom component '${componentLabel}' emitted invalid output \u2014 ${e.message}`
8322
+ })),
8323
+ emitted
8317
8324
  );
8318
- if (!result.valid) {
8319
- throw new ComponentValidationError2(
8320
- (result.errors ?? []).map((e) => ({
8321
- path: e.path ?? "",
8322
- message: `custom component '${componentLabel}' emitted invalid output \u2014 ${e.message}`
8323
- })),
8324
- emitted
8325
- );
8326
- }
8325
+ }
8326
+ };
8327
+ const warnings = [];
8328
+ const {
8329
+ document: modedRoot,
8330
+ theme: modedTheme,
8331
+ themeName
8332
+ } = resolveThemeContext(internalDocument, {
8333
+ customThemes: state.customThemes,
8334
+ fonts: state.fonts,
8335
+ warnings,
8336
+ resolveNamedTheme: resolveDocumentTheme
8337
+ });
8338
+ const processed = await processDocumentComponents(
8339
+ modedRoot.children || [],
8340
+ preserveSet,
8341
+ warnings,
8342
+ modedTheme,
8343
+ validateEmitted
8344
+ );
8345
+ const processedDocument = {
8346
+ ...modedRoot,
8347
+ children: processed.standard
8348
+ };
8349
+ const [modedDoc] = normalizeDocument(processedDocument);
8350
+ return {
8351
+ modedRoot,
8352
+ modedTheme,
8353
+ themeName,
8354
+ processed,
8355
+ modedDoc,
8356
+ warnings,
8357
+ preserveSet
8358
+ };
8359
+ }
8360
+ async function expandStandardDefinition(document, options) {
8361
+ try {
8362
+ const { modedDoc, warnings } = await expandDocument(document, options);
8363
+ return {
8364
+ standardDefinition: modedDoc,
8365
+ warnings: warnings.length > 0 ? warnings : null
8327
8366
  };
8328
- const warnings = [];
8367
+ } catch (error) {
8368
+ if (state.debug) {
8369
+ console.error("Document expansion error:", error);
8370
+ }
8371
+ throw error;
8372
+ }
8373
+ }
8374
+ async function generate(document, options) {
8375
+ try {
8329
8376
  const {
8330
- document: modedRoot,
8331
- theme: modedTheme,
8332
- themeName
8333
- } = resolveThemeContext(internalDocument, {
8334
- customThemes: state.customThemes,
8335
- fonts: state.fonts,
8336
- warnings,
8337
- resolveNamedTheme: resolveDocumentTheme
8338
- });
8339
- const processed = await processDocumentComponents(
8340
- modedRoot.children || [],
8341
- preserveSet,
8342
- warnings,
8377
+ modedRoot,
8343
8378
  modedTheme,
8344
- validateEmitted
8345
- );
8346
- const processedDocument = {
8347
- ...modedRoot,
8348
- children: processed.standard
8349
- };
8350
- const [modedDoc] = normalizeDocument(processedDocument);
8379
+ themeName,
8380
+ processed,
8381
+ modedDoc,
8382
+ warnings,
8383
+ preserveSet
8384
+ } = await expandDocument(document, options);
8351
8385
  await resolveDocumentFonts(modedDoc, modedTheme, state.fonts, warnings);
8352
8386
  const packageOptions = {
8353
8387
  deterministic: options?.deterministic ?? state.deterministic,
@@ -8474,6 +8508,7 @@ function createBuilderImpl(state) {
8474
8508
  generate,
8475
8509
  generateBuffer,
8476
8510
  generateFile,
8511
+ expandStandardDefinition,
8477
8512
  getComponentNames,
8478
8513
  validate,
8479
8514
  generateSchema,