@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.
package/dist/index.d.ts CHANGED
@@ -16,6 +16,6 @@ export { examples, getExample, getExampleNames, loadJsonExample, } from './templ
16
16
  export { runExample } from './utils/exampleRunner';
17
17
  import './components/index';
18
18
  export type { ChartGenerationResult, } from './components/highcharts';
19
- export { createComponent, createVersion, createDocumentGenerator, validateComponentProps, validateDocument, cleanComponentProps, ComponentValidationError, UnknownPreservedComponentError, generatePluginDocumentSchema, exportPluginSchema, generateComponentSchemas, mergeSchemas, type CustomComponent, type ComponentVersion, type ComponentVersionMap, type RenderFunction, type RenderContext as ComponentRenderContext, type DocumentGenerator, type DocumentGeneratorOptions, type GenerateOptions, type GenerateFileOptions, type GenerationResult, type BufferGenerationResult, type FileGenerationResult, type ValidationResult, type ValidationError, type ExtractCustomComponentType, type CustomComponentUnion, type ExtendedComponentDefinition, type ExtendedReportComponent, type InferCustomComponents, } from './plugin/index';
19
+ export { createComponent, createVersion, createDocumentGenerator, validateComponentProps, validateDocument, cleanComponentProps, ComponentValidationError, UnknownPreservedComponentError, generatePluginDocumentSchema, exportPluginSchema, generateComponentSchemas, mergeSchemas, type CustomComponent, type ComponentVersion, type ComponentVersionMap, type RenderFunction, type RenderContext as ComponentRenderContext, type DocumentGenerator, type DocumentGeneratorOptions, type GenerateOptions, type GenerateFileOptions, type GenerationResult, type BufferGenerationResult, type FileGenerationResult, type StandardDefinitionResult, type ValidationResult, type ValidationError, type ExtractCustomComponentType, type CustomComponentUnion, type ExtendedComponentDefinition, type ExtendedReportComponent, type InferCustomComponents, } from './plugin/index';
20
20
  export type { PluginComponent, PluginRenderFunction, PluginValidationError, PluginValidationResult, } from './types/plugin';
21
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,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f,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAGD,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,iBAAiB,IAAI,qBAAqB,GAC3C,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,uBAAuB,EAEvB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,+BAA+B,EACpC,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAEL,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAGvB,YAAY,EAEV,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,aAA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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
@@ -9001,70 +9001,104 @@ function createBuilderImpl(state) {
9001
9001
  }
9002
9002
  return new Set(list);
9003
9003
  }
9004
- async function generate(document, options) {
9005
- try {
9006
- const preserveSet = resolvePreserveSet(options);
9007
- const rootIn = document;
9008
- const internalDocument = rootIn.props === void 0 ? { ...rootIn, props: {} } : rootIn;
9009
- const vOpts = {
9010
- ...state.validation,
9011
- ...options?.validation
9012
- };
9013
- if (vOpts.enabled !== false) {
9014
- const result = validateDocument(
9015
- internalDocument,
9016
- state.components,
9017
- { allowUnknownFields: vOpts.allowUnknownFields }
9004
+ async function expandDocument(document, options) {
9005
+ const preserveSet = resolvePreserveSet(options);
9006
+ const rootIn = document;
9007
+ const internalDocument = rootIn.props === void 0 ? { ...rootIn, props: {} } : rootIn;
9008
+ const vOpts = {
9009
+ ...state.validation,
9010
+ ...options?.validation
9011
+ };
9012
+ if (vOpts.enabled !== false) {
9013
+ const result = validateDocument(
9014
+ internalDocument,
9015
+ state.components,
9016
+ { allowUnknownFields: vOpts.allowUnknownFields }
9017
+ );
9018
+ if (!result.valid) {
9019
+ throw new ComponentValidationError2(
9020
+ (result.errors ?? []).map((e) => ({
9021
+ path: e.path ?? "",
9022
+ message: e.message
9023
+ })),
9024
+ internalDocument
9018
9025
  );
9019
- if (!result.valid) {
9020
- throw new ComponentValidationError2(
9021
- (result.errors ?? []).map((e) => ({
9022
- path: e.path ?? "",
9023
- message: e.message
9024
- })),
9025
- internalDocument
9026
- );
9027
- }
9028
9026
  }
9029
- const validateEmitted = vOpts.enabled === false ? void 0 : (emitted, componentLabel) => {
9030
- const result = validateDocument(
9031
- { ...internalDocument, children: emitted },
9032
- state.components,
9033
- { allowUnknownFields: vOpts.allowUnknownFields }
9027
+ }
9028
+ const validateEmitted = vOpts.enabled === false ? void 0 : (emitted, componentLabel) => {
9029
+ const result = validateDocument(
9030
+ { ...internalDocument, children: emitted },
9031
+ state.components,
9032
+ { allowUnknownFields: vOpts.allowUnknownFields }
9033
+ );
9034
+ if (!result.valid) {
9035
+ throw new ComponentValidationError2(
9036
+ (result.errors ?? []).map((e) => ({
9037
+ path: e.path ?? "",
9038
+ message: `custom component '${componentLabel}' emitted invalid output \u2014 ${e.message}`
9039
+ })),
9040
+ emitted
9034
9041
  );
9035
- if (!result.valid) {
9036
- throw new ComponentValidationError2(
9037
- (result.errors ?? []).map((e) => ({
9038
- path: e.path ?? "",
9039
- message: `custom component '${componentLabel}' emitted invalid output \u2014 ${e.message}`
9040
- })),
9041
- emitted
9042
- );
9043
- }
9042
+ }
9043
+ };
9044
+ const warnings = [];
9045
+ const {
9046
+ document: modedRoot,
9047
+ theme: modedTheme,
9048
+ themeName
9049
+ } = resolveThemeContext(internalDocument, {
9050
+ customThemes: state.customThemes,
9051
+ fonts: state.fonts,
9052
+ warnings,
9053
+ resolveNamedTheme: resolveDocumentTheme
9054
+ });
9055
+ const processed = await processDocumentComponents(
9056
+ modedRoot.children || [],
9057
+ preserveSet,
9058
+ warnings,
9059
+ modedTheme,
9060
+ validateEmitted
9061
+ );
9062
+ const processedDocument = {
9063
+ ...modedRoot,
9064
+ children: processed.standard
9065
+ };
9066
+ const [modedDoc] = normalizeDocument(processedDocument);
9067
+ return {
9068
+ modedRoot,
9069
+ modedTheme,
9070
+ themeName,
9071
+ processed,
9072
+ modedDoc,
9073
+ warnings,
9074
+ preserveSet
9075
+ };
9076
+ }
9077
+ async function expandStandardDefinition(document, options) {
9078
+ try {
9079
+ const { modedDoc, warnings } = await expandDocument(document, options);
9080
+ return {
9081
+ standardDefinition: modedDoc,
9082
+ warnings: warnings.length > 0 ? warnings : null
9044
9083
  };
9045
- const warnings = [];
9084
+ } catch (error) {
9085
+ if (state.debug) {
9086
+ console.error("Document expansion error:", error);
9087
+ }
9088
+ throw error;
9089
+ }
9090
+ }
9091
+ async function generate(document, options) {
9092
+ try {
9046
9093
  const {
9047
- document: modedRoot,
9048
- theme: modedTheme,
9049
- themeName
9050
- } = resolveThemeContext(internalDocument, {
9051
- customThemes: state.customThemes,
9052
- fonts: state.fonts,
9053
- warnings,
9054
- resolveNamedTheme: resolveDocumentTheme
9055
- });
9056
- const processed = await processDocumentComponents(
9057
- modedRoot.children || [],
9058
- preserveSet,
9059
- warnings,
9094
+ modedRoot,
9060
9095
  modedTheme,
9061
- validateEmitted
9062
- );
9063
- const processedDocument = {
9064
- ...modedRoot,
9065
- children: processed.standard
9066
- };
9067
- const [modedDoc] = normalizeDocument(processedDocument);
9096
+ themeName,
9097
+ processed,
9098
+ modedDoc,
9099
+ warnings,
9100
+ preserveSet
9101
+ } = await expandDocument(document, options);
9068
9102
  await resolveDocumentFonts(modedDoc, modedTheme, state.fonts, warnings);
9069
9103
  const packageOptions = {
9070
9104
  deterministic: options?.deterministic ?? state.deterministic,
@@ -9191,6 +9225,7 @@ function createBuilderImpl(state) {
9191
9225
  generate,
9192
9226
  generateBuffer,
9193
9227
  generateFile,
9228
+ expandStandardDefinition,
9194
9229
  getComponentNames,
9195
9230
  validate,
9196
9231
  generateSchema,