@json-to-office/core-docx 0.9.0 → 0.13.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.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -56
- package/dist/index.js.map +1 -1
- package/dist/plugin/createDocumentGenerator.d.ts.map +1 -1
- package/dist/plugin/example/index.js +94 -56
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/plugin/index.d.ts +2 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +59 -6
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/validation.d.ts +1 -1
- package/dist/plugin/validation.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,aAAa,EAEd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AASxC,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;
|
|
1
|
+
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,aAAa,EAEd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AASxC,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;AA4ED;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC,CA+BhC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export { examples, getExample, getExampleNames, loadJsonExample, } from './templ
|
|
|
15
15
|
export { runExample } from './utils/exampleRunner';
|
|
16
16
|
import './components/index';
|
|
17
17
|
export type { ChartGenerationResult, } from './components/highcharts';
|
|
18
|
-
export { createComponent, createVersion, createDocumentGenerator, validateComponentProps, validateDocument, cleanComponentProps, ComponentValidationError, generatePluginDocumentSchema, exportPluginSchema, generateComponentSchemas, mergeSchemas, type CustomComponent, type ComponentVersion, type ComponentVersionMap, type RenderFunction, type RenderContext as ComponentRenderContext, type DocumentGenerator, type DocumentGeneratorOptions, type GenerationResult, type BufferGenerationResult, type FileGenerationResult, type ValidationResult, type ValidationError, type ExtractCustomComponentType, type CustomComponentUnion, type ExtendedComponentDefinition, type ExtendedReportComponent, type InferCustomComponents, } from './plugin/index';
|
|
18
|
+
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
19
|
export type { PluginComponent, PluginRenderFunction, PluginValidationError, PluginValidationResult, } from './types/plugin';
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
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;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,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,GACtB,MAAM,eAAe,CA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,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,QAAQ,EACR,UAAU,EACV,eAAe,EACf,eAAe,GAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,oBAAoB,CAAC;AAG5B,YAAY,EAEV,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAEL,eAAe,EACf,aAAa,EACb,uBAAuB,EAGvB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,8BAA8B,EAG9B,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EAGZ,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,aAAa,IAAI,sBAAsB,EAC5C,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,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
|
@@ -6215,9 +6215,10 @@ async function generateChart(config, servicesConfig) {
|
|
|
6215
6215
|
b64: true,
|
|
6216
6216
|
scale: config.scale
|
|
6217
6217
|
};
|
|
6218
|
+
const resolvedHeaders = typeof servicesConfig?.headers === "function" ? await servicesConfig.headers(requestBody) : servicesConfig?.headers;
|
|
6218
6219
|
const headers = {
|
|
6219
6220
|
"Content-Type": "application/json",
|
|
6220
|
-
...
|
|
6221
|
+
...resolvedHeaders
|
|
6221
6222
|
};
|
|
6222
6223
|
const response = await fetch(`${serverUrl}/export`, {
|
|
6223
6224
|
method: "POST",
|
|
@@ -7267,7 +7268,8 @@ import {
|
|
|
7267
7268
|
} from "@json-to-office/shared-docx/validation/unified";
|
|
7268
7269
|
import {
|
|
7269
7270
|
DuplicateComponentError,
|
|
7270
|
-
ComponentValidationError as ComponentValidationError2
|
|
7271
|
+
ComponentValidationError as ComponentValidationError2,
|
|
7272
|
+
UnknownPreservedComponentError
|
|
7271
7273
|
} from "@json-to-office/shared/plugin";
|
|
7272
7274
|
function validateComponentProps(schema, props, componentName) {
|
|
7273
7275
|
return validateCustomComponentProps(schema.propsSchema, props, {
|
|
@@ -7334,6 +7336,9 @@ function getValidatedProps(schema, props) {
|
|
|
7334
7336
|
}
|
|
7335
7337
|
var cleanComponentProps = getValidatedProps;
|
|
7336
7338
|
|
|
7339
|
+
// src/plugin/createDocumentGenerator.ts
|
|
7340
|
+
import { UnknownPreservedComponentError as UnknownPreservedComponentError2 } from "@json-to-office/shared/plugin";
|
|
7341
|
+
|
|
7337
7342
|
// src/plugin/schema.ts
|
|
7338
7343
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
7339
7344
|
import { latestVersion } from "@json-to-office/shared-docx";
|
|
@@ -7509,17 +7514,19 @@ function createBuilderImpl(state) {
|
|
|
7509
7514
|
}
|
|
7510
7515
|
return getThemeWithFallback(themeName);
|
|
7511
7516
|
}
|
|
7512
|
-
async function processDocumentComponents(components, warningsCollector, resolvedTheme, depth = 0) {
|
|
7517
|
+
async function processDocumentComponents(components, preserveSet, warningsCollector, resolvedTheme, depth = 0) {
|
|
7513
7518
|
if (depth > 20) {
|
|
7514
7519
|
throw new Error(
|
|
7515
7520
|
"Maximum component nesting depth exceeded (20). Check for circular component references."
|
|
7516
7521
|
);
|
|
7517
7522
|
}
|
|
7518
|
-
const
|
|
7523
|
+
const standardOut = [];
|
|
7524
|
+
const preservedOut = [];
|
|
7519
7525
|
for (const componentData of components) {
|
|
7520
7526
|
const componentName = componentData?.name;
|
|
7521
7527
|
if (!componentName) {
|
|
7522
|
-
|
|
7528
|
+
standardOut.push(componentData);
|
|
7529
|
+
preservedOut.push(componentData);
|
|
7523
7530
|
continue;
|
|
7524
7531
|
}
|
|
7525
7532
|
const customComponent = componentMap.get(componentName);
|
|
@@ -7542,12 +7549,14 @@ function createBuilderImpl(state) {
|
|
|
7542
7549
|
);
|
|
7543
7550
|
let nestedChildren;
|
|
7544
7551
|
if (componentWithName.children && Array.isArray(componentWithName.children)) {
|
|
7545
|
-
|
|
7552
|
+
const nested = await processDocumentComponents(
|
|
7546
7553
|
componentWithName.children,
|
|
7554
|
+
preserveSet,
|
|
7547
7555
|
warningsCollector,
|
|
7548
7556
|
resolvedTheme,
|
|
7549
7557
|
depth + 1
|
|
7550
7558
|
);
|
|
7559
|
+
nestedChildren = nested.standard;
|
|
7551
7560
|
}
|
|
7552
7561
|
const versionLabel = componentWithName.version ? `${customComponent.name}@${componentWithName.version}` : customComponent.name;
|
|
7553
7562
|
const addWarning = (message, context) => {
|
|
@@ -7567,15 +7576,21 @@ function createBuilderImpl(state) {
|
|
|
7567
7576
|
const resultComponents = Array.isArray(result) ? result : [result];
|
|
7568
7577
|
const processedResult = await processDocumentComponents(
|
|
7569
7578
|
resultComponents,
|
|
7579
|
+
preserveSet,
|
|
7570
7580
|
warningsCollector,
|
|
7571
7581
|
resolvedTheme,
|
|
7572
7582
|
depth + 1
|
|
7573
7583
|
);
|
|
7574
|
-
|
|
7584
|
+
standardOut.push(...processedResult.standard);
|
|
7585
|
+
if (preserveSet && preserveSet.has(componentName)) {
|
|
7586
|
+
preservedOut.push(componentData);
|
|
7587
|
+
} else {
|
|
7588
|
+
preservedOut.push(...processedResult.preserved);
|
|
7589
|
+
}
|
|
7575
7590
|
if (state.debug) {
|
|
7576
7591
|
console.log(
|
|
7577
7592
|
`Processed custom component '${versionLabel}':`,
|
|
7578
|
-
processedResult
|
|
7593
|
+
processedResult.standard
|
|
7579
7594
|
);
|
|
7580
7595
|
}
|
|
7581
7596
|
} catch (error) {
|
|
@@ -7590,20 +7605,26 @@ function createBuilderImpl(state) {
|
|
|
7590
7605
|
if ("children" in componentData && Array.isArray(componentData.children)) {
|
|
7591
7606
|
const processedNested = await processDocumentComponents(
|
|
7592
7607
|
componentData.children,
|
|
7608
|
+
preserveSet,
|
|
7593
7609
|
warningsCollector,
|
|
7594
7610
|
resolvedTheme,
|
|
7595
7611
|
depth + 1
|
|
7596
7612
|
);
|
|
7597
|
-
|
|
7613
|
+
standardOut.push({
|
|
7614
|
+
...componentData,
|
|
7615
|
+
children: processedNested.standard
|
|
7616
|
+
});
|
|
7617
|
+
preservedOut.push({
|
|
7598
7618
|
...componentData,
|
|
7599
|
-
children: processedNested
|
|
7619
|
+
children: processedNested.preserved
|
|
7600
7620
|
});
|
|
7601
7621
|
} else {
|
|
7602
|
-
|
|
7622
|
+
standardOut.push(componentData);
|
|
7623
|
+
preservedOut.push(componentData);
|
|
7603
7624
|
}
|
|
7604
7625
|
}
|
|
7605
7626
|
}
|
|
7606
|
-
return
|
|
7627
|
+
return { standard: standardOut, preserved: preservedOut };
|
|
7607
7628
|
}
|
|
7608
7629
|
function addComponent(component) {
|
|
7609
7630
|
if (!component.name) {
|
|
@@ -7628,8 +7649,24 @@ function createBuilderImpl(state) {
|
|
|
7628
7649
|
newState
|
|
7629
7650
|
);
|
|
7630
7651
|
}
|
|
7631
|
-
|
|
7652
|
+
function resolvePreserveSet(options) {
|
|
7653
|
+
const list = options?.preserveCustomComponents;
|
|
7654
|
+
if (!list || list.length === 0) {
|
|
7655
|
+
return void 0;
|
|
7656
|
+
}
|
|
7657
|
+
const registered = new Set(state.componentNames);
|
|
7658
|
+
const unknown = list.filter((n) => !registered.has(n));
|
|
7659
|
+
if (unknown.length > 0) {
|
|
7660
|
+
throw new UnknownPreservedComponentError2(
|
|
7661
|
+
unknown,
|
|
7662
|
+
Array.from(state.componentNames)
|
|
7663
|
+
);
|
|
7664
|
+
}
|
|
7665
|
+
return new Set(list);
|
|
7666
|
+
}
|
|
7667
|
+
async function generate(document, options) {
|
|
7632
7668
|
try {
|
|
7669
|
+
const preserveSet = resolvePreserveSet(options);
|
|
7633
7670
|
const internalDocument = document;
|
|
7634
7671
|
validateDocument(
|
|
7635
7672
|
internalDocument,
|
|
@@ -7653,14 +7690,15 @@ function createBuilderImpl(state) {
|
|
|
7653
7690
|
context: { code: w.code }
|
|
7654
7691
|
});
|
|
7655
7692
|
}
|
|
7656
|
-
const
|
|
7693
|
+
const processed = await processDocumentComponents(
|
|
7657
7694
|
mode.doc.children || [],
|
|
7695
|
+
preserveSet,
|
|
7658
7696
|
warnings,
|
|
7659
7697
|
modedTheme
|
|
7660
7698
|
);
|
|
7661
7699
|
const processedDocument = {
|
|
7662
7700
|
...mode.doc,
|
|
7663
|
-
children:
|
|
7701
|
+
children: processed.standard
|
|
7664
7702
|
};
|
|
7665
7703
|
const [modedDoc] = normalizeDocument(processedDocument);
|
|
7666
7704
|
await resolveDocumentFonts(modedDoc, modedTheme, state.fonts, warnings);
|
|
@@ -7669,9 +7707,15 @@ function createBuilderImpl(state) {
|
|
|
7669
7707
|
const generatedDocument = await renderDocument(structure, layout, {
|
|
7670
7708
|
services: state.services
|
|
7671
7709
|
});
|
|
7710
|
+
const preservedDefinition = preserveSet ? {
|
|
7711
|
+
...mode.doc,
|
|
7712
|
+
children: processed.preserved
|
|
7713
|
+
} : void 0;
|
|
7672
7714
|
return {
|
|
7673
7715
|
document: generatedDocument,
|
|
7674
|
-
warnings: warnings.length > 0 ? warnings : null
|
|
7716
|
+
warnings: warnings.length > 0 ? warnings : null,
|
|
7717
|
+
standardDefinition: modedDoc,
|
|
7718
|
+
preservedDefinition
|
|
7675
7719
|
};
|
|
7676
7720
|
} catch (error) {
|
|
7677
7721
|
if (state.debug) {
|
|
@@ -7680,16 +7724,40 @@ function createBuilderImpl(state) {
|
|
|
7680
7724
|
throw error;
|
|
7681
7725
|
}
|
|
7682
7726
|
}
|
|
7683
|
-
async function generateBuffer(document) {
|
|
7684
|
-
const {
|
|
7727
|
+
async function generateBuffer(document, options) {
|
|
7728
|
+
const {
|
|
7729
|
+
document: doc,
|
|
7730
|
+
warnings,
|
|
7731
|
+
standardDefinition,
|
|
7732
|
+
preservedDefinition
|
|
7733
|
+
} = await generate(document, options);
|
|
7685
7734
|
const buffer = await Packer2.toBuffer(doc);
|
|
7686
|
-
return { buffer, warnings };
|
|
7735
|
+
return { buffer, warnings, standardDefinition, preservedDefinition };
|
|
7687
7736
|
}
|
|
7688
|
-
async function generateFile(document, outputPath) {
|
|
7689
|
-
const { buffer, warnings } = await generateBuffer(document);
|
|
7737
|
+
async function generateFile(document, outputPath, options) {
|
|
7738
|
+
const { buffer, warnings, standardDefinition, preservedDefinition } = await generateBuffer(document, options);
|
|
7690
7739
|
const fs6 = await import("fs/promises");
|
|
7691
7740
|
await fs6.writeFile(outputPath, new Uint8Array(buffer));
|
|
7692
|
-
|
|
7741
|
+
let preservedOutputPath;
|
|
7742
|
+
if (preservedDefinition !== void 0) {
|
|
7743
|
+
const path4 = await import("path");
|
|
7744
|
+
preservedOutputPath = options?.preservedOutputPath ?? (() => {
|
|
7745
|
+
const ext = path4.extname(outputPath);
|
|
7746
|
+
const base = ext ? outputPath.slice(0, -ext.length) : outputPath;
|
|
7747
|
+
return `${base}-preserved.json`;
|
|
7748
|
+
})();
|
|
7749
|
+
await fs6.writeFile(
|
|
7750
|
+
preservedOutputPath,
|
|
7751
|
+
JSON.stringify(preservedDefinition, null, 2),
|
|
7752
|
+
"utf8"
|
|
7753
|
+
);
|
|
7754
|
+
}
|
|
7755
|
+
return {
|
|
7756
|
+
warnings,
|
|
7757
|
+
standardDefinition,
|
|
7758
|
+
preservedDefinition,
|
|
7759
|
+
preservedOutputPath
|
|
7760
|
+
};
|
|
7693
7761
|
}
|
|
7694
7762
|
function getComponentNames() {
|
|
7695
7763
|
return Array.from(state.componentNames);
|
|
@@ -7723,6 +7791,10 @@ function createBuilderImpl(state) {
|
|
|
7723
7791
|
};
|
|
7724
7792
|
}
|
|
7725
7793
|
}
|
|
7794
|
+
async function getStandardComponentsDefinition(document) {
|
|
7795
|
+
const { standardDefinition } = await generate(document);
|
|
7796
|
+
return standardDefinition;
|
|
7797
|
+
}
|
|
7726
7798
|
function generateSchema(includeStandardComponents = true) {
|
|
7727
7799
|
return generatePluginDocumentSchema(
|
|
7728
7800
|
state.components,
|
|
@@ -7736,40 +7808,6 @@ function createBuilderImpl(state) {
|
|
|
7736
7808
|
options
|
|
7737
7809
|
);
|
|
7738
7810
|
}
|
|
7739
|
-
async function getStandardComponentsDefinition(document) {
|
|
7740
|
-
try {
|
|
7741
|
-
const internalDocument = document;
|
|
7742
|
-
validateDocument(
|
|
7743
|
-
internalDocument,
|
|
7744
|
-
state.components
|
|
7745
|
-
);
|
|
7746
|
-
const themeName = internalDocument.props.theme || "minimal";
|
|
7747
|
-
const docTheme = resolveDocumentTheme(themeName);
|
|
7748
|
-
const warnings = [];
|
|
7749
|
-
const mode = applyExportMode2({
|
|
7750
|
-
doc: internalDocument,
|
|
7751
|
-
theme: docTheme,
|
|
7752
|
-
fonts: state.fonts
|
|
7753
|
-
});
|
|
7754
|
-
const modedTheme = mode.theme;
|
|
7755
|
-
const processedComponents = await processDocumentComponents(
|
|
7756
|
-
mode.doc.children || [],
|
|
7757
|
-
warnings,
|
|
7758
|
-
modedTheme
|
|
7759
|
-
);
|
|
7760
|
-
const processedDocument = {
|
|
7761
|
-
...mode.doc,
|
|
7762
|
-
children: processedComponents
|
|
7763
|
-
};
|
|
7764
|
-
const [finalReportComponent] = normalizeDocument(processedDocument);
|
|
7765
|
-
return finalReportComponent;
|
|
7766
|
-
} catch (error) {
|
|
7767
|
-
if (state.debug) {
|
|
7768
|
-
console.error("Error getting standard components definition:", error);
|
|
7769
|
-
}
|
|
7770
|
-
throw error;
|
|
7771
|
-
}
|
|
7772
|
-
}
|
|
7773
7811
|
return Object.freeze({
|
|
7774
7812
|
addComponent,
|
|
7775
7813
|
generate,
|
|
@@ -7815,6 +7853,7 @@ export {
|
|
|
7815
7853
|
ThemeFileError,
|
|
7816
7854
|
ThemeParseError,
|
|
7817
7855
|
ThemeValidationError,
|
|
7856
|
+
UnknownPreservedComponentError,
|
|
7818
7857
|
cleanComponentProps,
|
|
7819
7858
|
clearComponentCache,
|
|
7820
7859
|
corporateTheme,
|