@json-to-office/shared 2.5.0 → 3.0.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/{chunk-6TNT7DGC.js → chunk-LFHU4EOV.js} +5 -2
- package/dist/chunk-LFHU4EOV.js.map +1 -0
- package/dist/fonts/node.d.ts +9 -1
- package/dist/fonts/node.js +23 -0
- package/dist/fonts/node.js.map +1 -1
- package/dist/index.d.ts +411 -6
- package/dist/index.js +2021 -25
- package/dist/index.js.map +1 -1
- package/dist/{schema-utils-C5Qdzsgy.d.ts → schema-utils-B2i75lAT.d.ts} +7 -0
- package/dist/schemas/schema-utils.d.ts +1 -1
- package/dist/schemas/schema-utils.js +1 -1
- package/dist/schemas/slide-content.d.ts +16 -0
- package/dist/schemas/slide-content.js +22 -0
- package/dist/schemas/slide-content.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-6TNT7DGC.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { C as ComponentDefinition, a as ComponentSchemaConfig, c as convertToJsonSchema, b as createComponentSchema, d as createComponentSchemaObject, e as exportSchemaToFile, f as fixSchemaReferences } from './schema-utils-
|
|
1
|
+
export { C as ComponentDefinition, a as ComponentSchemaConfig, c as convertToJsonSchema, b as createComponentSchema, d as createComponentSchemaObject, e as exportSchemaToFile, f as fixSchemaReferences } from './schema-utils-B2i75lAT.js';
|
|
2
2
|
export { AddWarningFunction, GenerationWarning } from './types/warnings.js';
|
|
3
|
-
import { F as FontRegistryEntry, c as FontRuntimeOpts, R as ResolvedFontSource, b as ResolvedFont } from './types-kcQwhOlf.js';
|
|
4
|
-
export { D as DEFAULT_VISUAL_DPI, d as FontFamilyNameSchema, e as FontRegistryDefinition, f as FontRegistryEntrySchema, g as FontRegistrySchema, h as FontSource, i as FontSourceSchema, H as HighchartsHeaders, j as HighchartsHeadersResolver, k as HighchartsServiceConfig, M as MAX_RASTERIZE_BATCH_SLIDES, l as MAX_RASTERIZE_FONTS, m as MAX_RASTERIZE_FONT_BYTES, n as MAX_VISUAL_DPI, o as MIN_VISUAL_DPI, P as PptxBatchRasterizer, p as PptxRasterizeBatchRequest, q as PptxRasterizeBatchResult, r as PptxRasterizeBatchSlide, s as PptxRasterizeBatchSlideResult, t as PptxRasterizeFailureStage, u as PptxRasterizeRequest, v as PptxRasterizeResult, w as PptxRasterizer, x as PptxServiceConfig, y as PptxServiceHeaders, z as PptxServiceHeadersResolver,
|
|
5
|
-
|
|
3
|
+
import { F as FontRegistryEntry, c as FontRuntimeOpts, R as ResolvedFontSource, b as ResolvedFont, a as RasterizeFontFace } from './types-kcQwhOlf.js';
|
|
4
|
+
export { D as DEFAULT_VISUAL_DPI, d as FontFamilyNameSchema, e as FontRegistryDefinition, f as FontRegistryEntrySchema, g as FontRegistrySchema, h as FontSource, i as FontSourceSchema, H as HighchartsHeaders, j as HighchartsHeadersResolver, k as HighchartsServiceConfig, M as MAX_RASTERIZE_BATCH_SLIDES, l as MAX_RASTERIZE_FONTS, m as MAX_RASTERIZE_FONT_BYTES, n as MAX_VISUAL_DPI, o as MIN_VISUAL_DPI, P as PptxBatchRasterizer, p as PptxRasterizeBatchRequest, q as PptxRasterizeBatchResult, r as PptxRasterizeBatchSlide, s as PptxRasterizeBatchSlideResult, t as PptxRasterizeFailureStage, u as PptxRasterizeRequest, v as PptxRasterizeResult, w as PptxRasterizer, x as PptxServiceConfig, y as PptxServiceHeaders, z as PptxServiceHeadersResolver, S as SAFE_FONTS, A as SafeFontName, B as ServicesConfig, C as clampVisualDpi, E as isSafeFont } from './types-kcQwhOlf.js';
|
|
5
|
+
import { O as OfficeFormat } from './capabilities-DtPF3aBj.js';
|
|
6
|
+
export { F as FeatureRequirement, a as FeatureRequirementCollector, b as OfficeRenderer, R as RENDERER_DEPENDENCY_MISSING, c as RenderOptions, d as RendererDiagnostic, e as RendererDiagnosticSeverity, f as RendererRegistry, g as RendererStatus, h as UnsupportedRendererFeatureError, i as UnsupportedRendererFeatureErrorInit, j as assertNever, k as assertRendererSupports, l as diagnoseUnsupportedFeatures, p as partitionDiagnostics, r as rendererError, m as rendererWarning } from './capabilities-DtPF3aBj.js';
|
|
6
7
|
export { DEFAULT_ERROR_CONFIG, ERROR_EMOJIS, ErrorFormatterConfig, calculatePosition, clearComponentNamesCache, createErrorConfig, createJsonParseError, extractStandardComponentNames, formatErrorMessage, formatErrorSummary, getLiteralValue, getObjectSchemaPropertyNames, getSchemaMetadata, groupErrorsByPath, isLiteralSchema, isObjectSchema, isUnionSchema, transformValueError, transformValueErrors } from './validation/unified/index.js';
|
|
7
8
|
export { T as TransformedError, V as ValidationError, a as ValidationResult } from './types-BWFZ7OaO.js';
|
|
8
9
|
export { ComponentValidationError, ComponentValidationResult, ComponentVersion, ComponentVersionMap, CustomComponent, DuplicateComponentError, PluginValidationOptions, PluginValidationResult, RenderContext, RenderFunction, UnknownPreservedComponentError, createComponent, createVersion, getValidationSummary, isValidationSuccess, resolveComponentVersion, validateCustomComponentProps } from './plugin/index.js';
|
|
9
10
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
10
|
-
import { Static } from '@sinclair/typebox';
|
|
11
|
+
import { Static, TSchema } from '@sinclair/typebox';
|
|
11
12
|
export { ParsedSemver, compareSemver, isValidSemver, latestVersion, parseSemver } from './utils/semver.js';
|
|
12
13
|
import '@sinclair/typebox/value';
|
|
13
14
|
|
|
@@ -1612,6 +1613,410 @@ declare function resolveDesignColor(value: string, colors: Record<string, string
|
|
|
1612
1613
|
/** Reject dangling/cyclic new tokens before they can become invalid OOXML. */
|
|
1613
1614
|
declare function validateDesignColors(system: DesignSystem, colors: Record<string, string | undefined>): void;
|
|
1614
1615
|
|
|
1616
|
+
/**
|
|
1617
|
+
* The document's typography, expressed as Highcharts options.
|
|
1618
|
+
*
|
|
1619
|
+
* A `highcharts` component is a PNG drawn by a browser that has never seen the
|
|
1620
|
+
* document, so nothing about the page's type reaches the chart on its own: the
|
|
1621
|
+
* axis labels, title and legend come out in the export server's default face
|
|
1622
|
+
* at Highcharts' own sizes, visibly foreign to the prose around them. The
|
|
1623
|
+
* palette already carries (see `chart-palette.ts`); this carries the type.
|
|
1624
|
+
*
|
|
1625
|
+
* Format-neutral on purpose. Each core reads its own theme shape into a
|
|
1626
|
+
* `ChartTypography` — family, colours and sizes in document points — and this
|
|
1627
|
+
* module turns that into the option paths Highcharts styles text through. An
|
|
1628
|
+
* explicit author value keeps winning, property by property, exactly as
|
|
1629
|
+
* `options.colors` does.
|
|
1630
|
+
*
|
|
1631
|
+
* Sizes are converted from points to chart pixels through the scale the chart
|
|
1632
|
+
* is placed at: a 900px chart set into a 450pt measure shrinks by half, so a
|
|
1633
|
+
* label that must read as 9pt on the page is drawn at 18px.
|
|
1634
|
+
*/
|
|
1635
|
+
|
|
1636
|
+
interface ChartTypography {
|
|
1637
|
+
/** CSS `font-family` for everything not styled otherwise (see `cssFontFamily`). */
|
|
1638
|
+
bodyFamily: string;
|
|
1639
|
+
/** CSS `font-family` for the chart title. */
|
|
1640
|
+
headingFamily: string;
|
|
1641
|
+
/** `#RRGGBB` for the title, legend and data labels. */
|
|
1642
|
+
textColor: string;
|
|
1643
|
+
/** `#RRGGBB` for axis text, subtitle, caption and credits. */
|
|
1644
|
+
mutedColor: string;
|
|
1645
|
+
/** Axis labels, axis titles, legend, subtitle and data labels, in points. */
|
|
1646
|
+
labelPt: number;
|
|
1647
|
+
/** Weight for legend items and data labels; Highcharts' own default when unset. */
|
|
1648
|
+
labelWeight?: number;
|
|
1649
|
+
/** Chart title, in points. */
|
|
1650
|
+
titlePt: number;
|
|
1651
|
+
/** Chart title weight; Highcharts' own default when unset. */
|
|
1652
|
+
titleWeight?: number;
|
|
1653
|
+
/** Credits (the source line) and caption, in points. */
|
|
1654
|
+
sourcePt: number;
|
|
1655
|
+
}
|
|
1656
|
+
/** Points per CSS pixel at the 96 dpi both formats assume for an unplaced chart. */
|
|
1657
|
+
declare const POINTS_PER_PIXEL_96DPI = 0.75;
|
|
1658
|
+
/**
|
|
1659
|
+
* How many document points one chart pixel occupies once the image is placed.
|
|
1660
|
+
* Unknown or degenerate widths fall back to 96 dpi, the size an unscaled
|
|
1661
|
+
* chart has in both formats.
|
|
1662
|
+
*/
|
|
1663
|
+
declare function chartPointsPerPixel(chartWidthPx: number, placedWidthPt: number | undefined): number;
|
|
1664
|
+
type FontCategory = NonNullable<FontRegistryEntry['category']>;
|
|
1665
|
+
/**
|
|
1666
|
+
* A CSS `font-family` list: the family, quoted, then the generic it belongs
|
|
1667
|
+
* to — from the registry category when the font is registered, from the
|
|
1668
|
+
* SAFE_FONTS list otherwise — so a face the export server lacks degrades to
|
|
1669
|
+
* the right shape rather than to the browser's default.
|
|
1670
|
+
*/
|
|
1671
|
+
declare function cssFontFamily(family: string, category?: FontCategory): string;
|
|
1672
|
+
/**
|
|
1673
|
+
* `cssFontFamily` bound to a theme: a registered family answers with its
|
|
1674
|
+
* registry category, an unregistered one with what SAFE_FONTS says of it.
|
|
1675
|
+
*/
|
|
1676
|
+
declare function chartFamilyResolver(theme: unknown): (family: string) => string;
|
|
1677
|
+
type Options = Record<string, unknown>;
|
|
1678
|
+
/**
|
|
1679
|
+
* The document's typography written into every Highcharts option path that
|
|
1680
|
+
* styles text, beneath whatever the author set. `ptPerPx` is the placement
|
|
1681
|
+
* scale from `chartPointsPerPixel`.
|
|
1682
|
+
*/
|
|
1683
|
+
declare function withChartTypography<T extends Options>(options: T, typography: ChartTypography, ptPerPx: number): T;
|
|
1684
|
+
/**
|
|
1685
|
+
* `@font-face` rules for the faces of `families`, inlined as data URIs, so an
|
|
1686
|
+
* export server draws a registered font from the same bytes the document
|
|
1687
|
+
* stages rather than from whatever its host happens to have installed. The
|
|
1688
|
+
* bytes go only to the export server, which already receives every data
|
|
1689
|
+
* point of the chart. Empty when no face matches.
|
|
1690
|
+
*/
|
|
1691
|
+
declare function chartFontFaceCss(faces: readonly RasterizeFontFace[], families: readonly string[]): string;
|
|
1692
|
+
/**
|
|
1693
|
+
* The `@font-face` rules for `families` written into a chart's `resources.css`
|
|
1694
|
+
* ahead of whatever the author supplied there. Nothing changes when no face
|
|
1695
|
+
* matches, so a chart set in safe fonts posts the same request it always did.
|
|
1696
|
+
*/
|
|
1697
|
+
declare function withChartFontFaceCss<T extends {
|
|
1698
|
+
resources?: {
|
|
1699
|
+
css?: string;
|
|
1700
|
+
};
|
|
1701
|
+
}>(props: T, faces: readonly RasterizeFontFace[], families: readonly string[]): T;
|
|
1702
|
+
|
|
1703
|
+
/**
|
|
1704
|
+
* Content roles a definition may assign to a slot. A quality profile reads
|
|
1705
|
+
* them to require or measure content (an action title at most two lines, a
|
|
1706
|
+
* source under every chart); the theme only styles them. No role adds a
|
|
1707
|
+
* requirement on its own.
|
|
1708
|
+
*/
|
|
1709
|
+
declare const BLOCK_SLOT_ROLES: readonly ["actionTitle", "takeaway", "source", "tracker", "footer"];
|
|
1710
|
+
type BlockSlotRole = (typeof BLOCK_SLOT_ROLES)[number];
|
|
1711
|
+
interface BlockSlot {
|
|
1712
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'component';
|
|
1713
|
+
description?: string;
|
|
1714
|
+
required?: boolean;
|
|
1715
|
+
default?: unknown;
|
|
1716
|
+
enum?: (string | number | boolean)[];
|
|
1717
|
+
minItems?: number;
|
|
1718
|
+
maxItems?: number;
|
|
1719
|
+
minLength?: number;
|
|
1720
|
+
maxLength?: number;
|
|
1721
|
+
minimum?: number;
|
|
1722
|
+
maximum?: number;
|
|
1723
|
+
maxWords?: number;
|
|
1724
|
+
oneLine?: boolean;
|
|
1725
|
+
items?: BlockSlot;
|
|
1726
|
+
properties?: Record<string, BlockSlot>;
|
|
1727
|
+
role?: BlockSlotRole;
|
|
1728
|
+
}
|
|
1729
|
+
/** Definitions are authored data. No concrete block is registered by the core. */
|
|
1730
|
+
interface JsonBlockDefinition {
|
|
1731
|
+
description?: string;
|
|
1732
|
+
slots: Record<string, BlockSlot>;
|
|
1733
|
+
body: unknown[];
|
|
1734
|
+
/** DOCX section state, applied before rendering its header and footer. */
|
|
1735
|
+
section?: {
|
|
1736
|
+
tracker?: unknown;
|
|
1737
|
+
header?: unknown[];
|
|
1738
|
+
footer?: unknown[];
|
|
1739
|
+
pageBreak?: boolean;
|
|
1740
|
+
scope?: 'section' | 'following';
|
|
1741
|
+
};
|
|
1742
|
+
/** PPTX slide settings the invocation's slide inherits unless it states its own. */
|
|
1743
|
+
slide?: {
|
|
1744
|
+
background?: unknown;
|
|
1745
|
+
grid?: unknown;
|
|
1746
|
+
notes?: unknown;
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
declare const BlockSlotSchema: TSchema;
|
|
1750
|
+
declare const JsonBlockDefinitionSchema: _sinclair_typebox.TUnsafe<JsonBlockDefinition>;
|
|
1751
|
+
declare const BlockDefinitionsSchema: _sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TUnsafe<JsonBlockDefinition>>;
|
|
1752
|
+
declare const BlockInvocationPropsSchema: _sinclair_typebox.TObject<{
|
|
1753
|
+
ref: _sinclair_typebox.TString;
|
|
1754
|
+
slots: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TUnknown>>;
|
|
1755
|
+
}>;
|
|
1756
|
+
/** Portable JSON Schema for a single slot, also used by catalog/inspect clients. */
|
|
1757
|
+
declare function blockSlotJsonSchema(slot: BlockSlot): Record<string, unknown>;
|
|
1758
|
+
|
|
1759
|
+
type Rec$1 = Record<string, unknown>;
|
|
1760
|
+
interface BlockIssue {
|
|
1761
|
+
path: string;
|
|
1762
|
+
code: string;
|
|
1763
|
+
message: string;
|
|
1764
|
+
}
|
|
1765
|
+
declare class BlockEvaluationError extends Error {
|
|
1766
|
+
readonly issues: BlockIssue[];
|
|
1767
|
+
constructor(issues: BlockIssue[]);
|
|
1768
|
+
}
|
|
1769
|
+
declare const isBlockRecord: (v: unknown) => v is Rec$1;
|
|
1770
|
+
declare const blockPointerKey: (s: string) => string;
|
|
1771
|
+
declare function blockValueAt(root: unknown, path: string): unknown;
|
|
1772
|
+
declare function toAuthoredBlockPointer(map: Readonly<Record<string, string>>, pointer: string): string;
|
|
1773
|
+
/**
|
|
1774
|
+
* Props a component placed in a slot may not carry: placement and group
|
|
1775
|
+
* layout belong to the definition. Read by the runtime check below and by the
|
|
1776
|
+
* editor schema that flags them inline.
|
|
1777
|
+
*/
|
|
1778
|
+
declare const BLOCK_SLOT_PLACEMENT_PROPS: readonly string[];
|
|
1779
|
+
declare const blockWordCount: (text: string) => number;
|
|
1780
|
+
/** Slot constraints and defaults are shared by validation and evaluation. */
|
|
1781
|
+
declare function resolveBlockSlot(slot: BlockSlot, input: unknown, path: string, issues: BlockIssue[]): unknown;
|
|
1782
|
+
declare function readBlockDefinitions(document: unknown): Record<string, JsonBlockDefinition>;
|
|
1783
|
+
declare function validateBlockDefinitions(definitions: unknown, format: 'docx' | 'pptx', reservedNames?: readonly string[]): BlockIssue[];
|
|
1784
|
+
declare function validateBlockInvocations(document: unknown, definitions: Record<string, JsonBlockDefinition>, format: 'docx' | 'pptx', reservedNames?: readonly string[]): BlockIssue[];
|
|
1785
|
+
interface BlockEnvironment {
|
|
1786
|
+
slots: Rec$1;
|
|
1787
|
+
slotSources?: Record<string, string>;
|
|
1788
|
+
source: string;
|
|
1789
|
+
definition: string;
|
|
1790
|
+
context: Rec$1;
|
|
1791
|
+
contextSources?: Record<string, string>;
|
|
1792
|
+
item?: unknown;
|
|
1793
|
+
itemSource?: string;
|
|
1794
|
+
}
|
|
1795
|
+
interface BlockSectionEffect {
|
|
1796
|
+
settings: NonNullable<JsonBlockDefinition['section']>;
|
|
1797
|
+
environment: BlockEnvironment;
|
|
1798
|
+
path: string;
|
|
1799
|
+
}
|
|
1800
|
+
interface BlockSlideEffect {
|
|
1801
|
+
settings: NonNullable<JsonBlockDefinition['slide']>;
|
|
1802
|
+
environment: BlockEnvironment;
|
|
1803
|
+
path: string;
|
|
1804
|
+
}
|
|
1805
|
+
interface BlockEvaluatorOptions {
|
|
1806
|
+
format: 'docx' | 'pptx';
|
|
1807
|
+
theme?: unknown;
|
|
1808
|
+
context?: Rec$1;
|
|
1809
|
+
contextSources?: Record<string, string>;
|
|
1810
|
+
reservedNames?: readonly string[];
|
|
1811
|
+
contextAt?: (path: string) => Rec$1;
|
|
1812
|
+
measure?: (axis: 'width' | 'height', unit: 'pt' | 'twip' | 'in', context: Rec$1) => number;
|
|
1813
|
+
onSection?: (effect: BlockSectionEffect) => void;
|
|
1814
|
+
onSlide?: (effect: BlockSlideEffect) => void;
|
|
1815
|
+
}
|
|
1816
|
+
/** Pure bounded JSON composition. Plugins are expanded by the host, never evaluated here. */
|
|
1817
|
+
declare class JsonBlockEvaluator {
|
|
1818
|
+
readonly definitions: Record<string, JsonBlockDefinition>;
|
|
1819
|
+
readonly options: BlockEvaluatorOptions;
|
|
1820
|
+
readonly sourceMap: Record<string, string>;
|
|
1821
|
+
readonly blocks: string[];
|
|
1822
|
+
private nodes;
|
|
1823
|
+
constructor(definitions: Record<string, JsonBlockDefinition>, options: BlockEvaluatorOptions);
|
|
1824
|
+
private guard;
|
|
1825
|
+
evaluate(value: unknown, env: BlockEnvironment, out: string, definitionPath: string, depth?: number): unknown;
|
|
1826
|
+
expand(value: unknown, path?: string, depth?: number): unknown;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
declare function blockSlotsJsonSchema(definition: JsonBlockDefinition): Record<string, unknown>;
|
|
1830
|
+
/** Authored definitions and fill pointers for exactly this document revision. */
|
|
1831
|
+
declare function documentBlockMetadata(document: unknown): {
|
|
1832
|
+
definitions: {
|
|
1833
|
+
name: string;
|
|
1834
|
+
definitionPointer: string;
|
|
1835
|
+
definition: JsonBlockDefinition;
|
|
1836
|
+
slotsSchema: Record<string, unknown>;
|
|
1837
|
+
}[];
|
|
1838
|
+
invocations: {
|
|
1839
|
+
ref: string;
|
|
1840
|
+
path: string;
|
|
1841
|
+
slotsPath: string;
|
|
1842
|
+
defined: boolean;
|
|
1843
|
+
}[];
|
|
1844
|
+
invalidDefinitions: boolean;
|
|
1845
|
+
};
|
|
1846
|
+
/** Compiled pointer → authored pointer. */
|
|
1847
|
+
type BlockSourceMap = Readonly<Record<string, string>>;
|
|
1848
|
+
/** A document with every block lowered in place, and how to get back. */
|
|
1849
|
+
interface ExpandedBlocks<T> {
|
|
1850
|
+
document: T;
|
|
1851
|
+
sourceMap: BlockSourceMap;
|
|
1852
|
+
/** Authored pointers of every expanded invocation, in document order. */
|
|
1853
|
+
blocks: readonly string[];
|
|
1854
|
+
}
|
|
1855
|
+
interface BlockSlotBudget {
|
|
1856
|
+
block: string;
|
|
1857
|
+
slot: string;
|
|
1858
|
+
path: string;
|
|
1859
|
+
words: number;
|
|
1860
|
+
maxWords: number;
|
|
1861
|
+
}
|
|
1862
|
+
interface BlockSlotRoleValue {
|
|
1863
|
+
block: string;
|
|
1864
|
+
/** Authored pointer of the invocation. */
|
|
1865
|
+
invocation: string;
|
|
1866
|
+
slot: string;
|
|
1867
|
+
role: BlockSlotRole;
|
|
1868
|
+
/** Authored pointer of the slot value, whether or not one was supplied. */
|
|
1869
|
+
path: string;
|
|
1870
|
+
/** The resolved value after defaults; undefined when absent. */
|
|
1871
|
+
value: unknown;
|
|
1872
|
+
}
|
|
1873
|
+
/** Metadata is always read from authored definitions, never from a named catalog. */
|
|
1874
|
+
declare function blockSlotBudgets(document: unknown, blocks: readonly string[]): BlockSlotBudget[];
|
|
1875
|
+
/**
|
|
1876
|
+
* Every role-bearing slot of every invocation, present or not, so a profile
|
|
1877
|
+
* can require one (a source under a chart) and measure another (an action
|
|
1878
|
+
* title's length) at the authored pointer the author can patch.
|
|
1879
|
+
*/
|
|
1880
|
+
declare function blockSlotRoles(document: unknown, blocks: readonly string[]): BlockSlotRoleValue[];
|
|
1881
|
+
|
|
1882
|
+
type Schema$1 = Record<string, any>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Derive authoring from the renderer/plugin schemas without weakening ordinary
|
|
1885
|
+
* documents. Each value retains its literal schema and receives only directives
|
|
1886
|
+
* whose result family can fit. Defaults and conditional branches recurse into
|
|
1887
|
+
* that same value schema; repetition templates use the actual array item schema.
|
|
1888
|
+
*
|
|
1889
|
+
* Dispatch uses standard draft-07 conditionals, not overlapping anyOf branches:
|
|
1890
|
+
* existing literal keys keep literal completion, and a directive selects only
|
|
1891
|
+
* its own options. Empty/incomplete objects offer literal keys and directive
|
|
1892
|
+
* starters. Memoized references keep recursive schemas finite and avoid copying
|
|
1893
|
+
* the component graph into every default/then/else branch.
|
|
1894
|
+
*/
|
|
1895
|
+
declare function createBlockAuthoringSchema(definitions: Record<string, Schema$1>, componentDefinition: string, excludedComponents?: readonly string[], format?: OfficeFormat): Schema$1;
|
|
1896
|
+
|
|
1897
|
+
type Rec = Record<string, unknown>;
|
|
1898
|
+
interface BlockCompositionOptions {
|
|
1899
|
+
/** Registered code component names. JSON never loads or installs them. */
|
|
1900
|
+
plugins: ReadonlySet<string>;
|
|
1901
|
+
/** Expand one registered component at its authored path into standard output. */
|
|
1902
|
+
render: (component: Rec, path: string) => Promise<unknown[]>;
|
|
1903
|
+
/** Plugin names kept unexpanded in the `preserved` tree (schema export, inspection). */
|
|
1904
|
+
preserve?: ReadonlySet<string>;
|
|
1905
|
+
}
|
|
1906
|
+
interface BlockComposition {
|
|
1907
|
+
/** Every block and plugin lowered to standard components. */
|
|
1908
|
+
standard: unknown;
|
|
1909
|
+
/** The same tree with preserved plugins left as authored. */
|
|
1910
|
+
preserved: unknown;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* One bounded expansion for document-local JSON and registered code, in both
|
|
1914
|
+
* directions: a plugin can emit a block, a block body or component slot can
|
|
1915
|
+
* name a plugin, and either can nest. Provenance survives each boundary
|
|
1916
|
+
* through the evaluator's source map; emitted output is wrapped in a `group`
|
|
1917
|
+
* whose pointer maps back to the plugin's authored node.
|
|
1918
|
+
*
|
|
1919
|
+
* Format-neutral: the host supplies the evaluator (its format, theme and
|
|
1920
|
+
* context) and validates the finished tree.
|
|
1921
|
+
*/
|
|
1922
|
+
declare function composeBlocksWithPlugins(evaluator: JsonBlockEvaluator, document: unknown, options: BlockCompositionOptions): Promise<BlockComposition>;
|
|
1923
|
+
|
|
1924
|
+
type Schema = Record<string, any>;
|
|
1925
|
+
/** A block invocation as authored: the component the editor inserts. */
|
|
1926
|
+
interface BlockInvocationExample {
|
|
1927
|
+
name: 'block';
|
|
1928
|
+
props: {
|
|
1929
|
+
ref: string;
|
|
1930
|
+
slots?: Record<string, unknown>;
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* A slot's contract as short facts, in one order, for every place that shows
|
|
1935
|
+
* it: the editor hover, the AI prompt, a catalog summary. "Required" means
|
|
1936
|
+
* the caller must supply a value — a slot with a default never is.
|
|
1937
|
+
*/
|
|
1938
|
+
declare function blockSlotFacts(slot: BlockSlot): string[];
|
|
1939
|
+
/** The hover text for a slot: its description, then its contract in one line. */
|
|
1940
|
+
declare function blockSlotMarkdown(slot: BlockSlot): string;
|
|
1941
|
+
/**
|
|
1942
|
+
* JSON Schema for one slot as the editor should see it. Unlike the portable
|
|
1943
|
+
* `blockSlotJsonSchema`, a component slot references the real component
|
|
1944
|
+
* definition — so a chart placed in it completes like any other chart — with
|
|
1945
|
+
* the placement props the runtime rejects flagged at the key they appear on.
|
|
1946
|
+
*/
|
|
1947
|
+
declare function blockSlotEditorSchema(slot: BlockSlot, componentRef?: Schema): Schema;
|
|
1948
|
+
/** The `slots` object of an invocation of this definition. */
|
|
1949
|
+
declare function blockSlotsEditorSchema(definition: JsonBlockDefinition, componentRef?: Schema): Schema;
|
|
1950
|
+
/**
|
|
1951
|
+
* The `props` of a `block` component given this document's definitions:
|
|
1952
|
+
* `ref` enumerates the names with their descriptions, and each name
|
|
1953
|
+
* dispatches `slots` to its own schema. With no definitions the reference
|
|
1954
|
+
* stays a free string — the runtime says which name is missing.
|
|
1955
|
+
*/
|
|
1956
|
+
declare function blockInvocationPropsSchema(definitions: Record<string, JsonBlockDefinition>, componentRef?: Schema): Schema;
|
|
1957
|
+
/** Where the document-aware invocation props go in an exported schema. */
|
|
1958
|
+
interface DocumentBlockTarget {
|
|
1959
|
+
/** A component definition under `definitions`, typically one per renderer. */
|
|
1960
|
+
name: string;
|
|
1961
|
+
/**
|
|
1962
|
+
* What a component slot accepts — the content a slide or a section holds,
|
|
1963
|
+
* as a reference into the same schema. Omitted, a component slot only asks
|
|
1964
|
+
* for a `name`.
|
|
1965
|
+
*/
|
|
1966
|
+
componentRef?: Schema;
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* Install the document-aware invocation props on every `block` branch inside
|
|
1970
|
+
* the targeted component definitions — the definition's own branch and the
|
|
1971
|
+
* copies a container inlines for its children — so an invocation completes
|
|
1972
|
+
* the same wherever a slide or section places it. References out of the
|
|
1973
|
+
* definition are not followed: block bodies live in their own derived
|
|
1974
|
+
* definitions and keep their binding-aware props. Mutates in place; call on
|
|
1975
|
+
* a copy of the shared schema.
|
|
1976
|
+
*/
|
|
1977
|
+
declare function applyDocumentBlocksToSchema(schema: Schema, definitions: Record<string, JsonBlockDefinition>, targets: readonly DocumentBlockTarget[]): void;
|
|
1978
|
+
/**
|
|
1979
|
+
* The definitions a block needs beside itself, dependencies first, so a
|
|
1980
|
+
* copied definition never leaves an unresolved reference behind. Unknown
|
|
1981
|
+
* references and cycles are skipped: the runtime reports those.
|
|
1982
|
+
*/
|
|
1983
|
+
declare function blockDependencies(definitions: Record<string, JsonBlockDefinition>, name: string): string[];
|
|
1984
|
+
/**
|
|
1985
|
+
* A valid invocation to insert: the first one the source document makes, if
|
|
1986
|
+
* it makes one — real content, at the cardinality its author chose — else
|
|
1987
|
+
* one synthesized from the slots at typical cardinality.
|
|
1988
|
+
*/
|
|
1989
|
+
declare function blockInvocationExample(name: string, definition: JsonBlockDefinition, options: {
|
|
1990
|
+
document?: unknown;
|
|
1991
|
+
format: OfficeFormat;
|
|
1992
|
+
}): BlockInvocationExample;
|
|
1993
|
+
/** An authoring reference extracted from a complete document. */
|
|
1994
|
+
interface BlockReference {
|
|
1995
|
+
name: string;
|
|
1996
|
+
format: OfficeFormat;
|
|
1997
|
+
/** The document the definition comes from. */
|
|
1998
|
+
template: string;
|
|
1999
|
+
definitionPointer: string;
|
|
2000
|
+
description: string;
|
|
2001
|
+
definition: JsonBlockDefinition;
|
|
2002
|
+
/** Portable slot schema, as `jto://blocks` publishes it. */
|
|
2003
|
+
slotsSchema: Record<string, unknown>;
|
|
2004
|
+
/** A valid invocation at typical cardinality. */
|
|
2005
|
+
example: BlockInvocationExample;
|
|
2006
|
+
/** Other definitions of the same document this one invokes, dependencies first. */
|
|
2007
|
+
dependencies: string[];
|
|
2008
|
+
}
|
|
2009
|
+
/**
|
|
2010
|
+
* Every block a complete document defines, as a reference an editor or an
|
|
2011
|
+
* agent can copy: definition, dependencies and a working invocation. A
|
|
2012
|
+
* document whose definitions do not validate contributes nothing — a
|
|
2013
|
+
* reference must be copyable as is.
|
|
2014
|
+
*/
|
|
2015
|
+
declare function blockReferencesFromDocument(document: unknown, source: {
|
|
2016
|
+
template: string;
|
|
2017
|
+
format: OfficeFormat;
|
|
2018
|
+
}): BlockReference[];
|
|
2019
|
+
|
|
1615
2020
|
/**
|
|
1616
2021
|
* Deep Merge Utilities
|
|
1617
2022
|
* Generic deep-merge helpers used by both docx and pptx
|
|
@@ -1625,4 +2030,4 @@ declare function validateDesignColors(system: DesignSystem, colors: Record<strin
|
|
|
1625
2030
|
*/
|
|
1626
2031
|
declare function mergeWithDefaults<T>(userConfig: T, themeDefaults: Partial<T>): T;
|
|
1627
2032
|
|
|
1628
|
-
export { CANVASES, ChromeSchema, DEFAULT_CHART_THEME_COLORS, type DesignCanvas, DesignSpacingSchema, type DesignSystem, DesignSystemProperties, DesignSystemSchema, FONT_URL_ALLOWLIST, type FontIssueCode, FontRegistry, FontRegistryEntry, type FontRegistryInput, type FontResolutionIssue, FontRuntimeOpts, type FontSubstitution, type FontValidationInput, type FontValidationResult, MotifSchema, POPULAR_GOOGLE_FONTS, PaletteSchema, type PopularGoogleFont, ROLE_SCALE_STEPS, ResolvedFont, ResolvedFontSource, type SynthesizedFamily, TYPE_ROLES, TextCaseSchema, type TypeRole, type TypeRoleName, TypeRoleNameSchema, TypeRoleSchema, TypeRolesSchema, TypographySchema, UPSTREAM_OVERRIDES, type UpstreamOverride, type UpstreamVariant, WEIGHT_LABELS, applyExportMode, applyFontSubstitution, buildDefaultSubstitutionMap, capsFormatting, collectFontNamesFromDocx, collectFontNamesFromPptx, defaultSubstituteFor, designCanvas, designColors, detectFontFormat, documentFontRegistry, fetchGoogleFontSources, getUpstreamOverride, isAllowedFontUrl, mergeFontRegistries, mergeWithDefaults, resolveDesignColor, resolveTypeRoles, restructureNameDiscriminatedUnions, rewriteFontFamilyName, synthesizeFamilyName, themeFontRegistry, unionBranches, validateDesignColors, validateFontReferences };
|
|
2033
|
+
export { BLOCK_SLOT_PLACEMENT_PROPS, BLOCK_SLOT_ROLES, type BlockComposition, type BlockCompositionOptions, BlockDefinitionsSchema, type BlockEnvironment, BlockEvaluationError, type BlockEvaluatorOptions, type BlockInvocationExample, BlockInvocationPropsSchema, type BlockIssue, type BlockReference, type BlockSectionEffect, type BlockSlideEffect, type BlockSlot, type BlockSlotBudget, type BlockSlotRole, type BlockSlotRoleValue, BlockSlotSchema, type BlockSourceMap, CANVASES, type ChartTypography, ChromeSchema, DEFAULT_CHART_THEME_COLORS, type DesignCanvas, DesignSpacingSchema, type DesignSystem, DesignSystemProperties, DesignSystemSchema, type DocumentBlockTarget, type ExpandedBlocks, FONT_URL_ALLOWLIST, type FontIssueCode, FontRegistry, FontRegistryEntry, type FontRegistryInput, type FontResolutionIssue, FontRuntimeOpts, type FontSubstitution, type FontValidationInput, type FontValidationResult, type JsonBlockDefinition, JsonBlockDefinitionSchema, JsonBlockEvaluator, MotifSchema, OfficeFormat, POINTS_PER_PIXEL_96DPI, POPULAR_GOOGLE_FONTS, PaletteSchema, type PopularGoogleFont, ROLE_SCALE_STEPS, RasterizeFontFace, ResolvedFont, ResolvedFontSource, type SynthesizedFamily, TYPE_ROLES, TextCaseSchema, type TypeRole, type TypeRoleName, TypeRoleNameSchema, TypeRoleSchema, TypeRolesSchema, TypographySchema, UPSTREAM_OVERRIDES, type UpstreamOverride, type UpstreamVariant, WEIGHT_LABELS, applyDocumentBlocksToSchema, applyExportMode, applyFontSubstitution, blockDependencies, blockInvocationExample, blockInvocationPropsSchema, blockPointerKey, blockReferencesFromDocument, blockSlotBudgets, blockSlotEditorSchema, blockSlotFacts, blockSlotJsonSchema, blockSlotMarkdown, blockSlotRoles, blockSlotsEditorSchema, blockSlotsJsonSchema, blockValueAt, blockWordCount, buildDefaultSubstitutionMap, capsFormatting, chartFamilyResolver, chartFontFaceCss, chartPointsPerPixel, collectFontNamesFromDocx, collectFontNamesFromPptx, composeBlocksWithPlugins, createBlockAuthoringSchema, cssFontFamily, defaultSubstituteFor, designCanvas, designColors, detectFontFormat, documentBlockMetadata, documentFontRegistry, fetchGoogleFontSources, getUpstreamOverride, isAllowedFontUrl, isBlockRecord, mergeFontRegistries, mergeWithDefaults, readBlockDefinitions, resolveBlockSlot, resolveDesignColor, resolveTypeRoles, restructureNameDiscriminatedUnions, rewriteFontFamilyName, synthesizeFamilyName, themeFontRegistry, toAuthoredBlockPointer, unionBranches, validateBlockDefinitions, validateBlockInvocations, validateDesignColors, validateFontReferences, withChartFontFaceCss, withChartTypography };
|