@json-to-office/shared 0.16.0 → 0.22.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-6KUQYVPT.js +177 -0
- package/dist/chunk-6KUQYVPT.js.map +1 -0
- package/dist/{chunk-TDDHCW5S.js → chunk-GPNPMKVZ.js} +5 -5
- package/dist/index.d.ts +38 -1
- package/dist/index.js +33 -182
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.js +2 -2
- package/dist/schemas/slide-content.d.ts +968 -0
- package/dist/schemas/slide-content.js +1182 -0
- package/dist/schemas/slide-content.js.map +1 -0
- package/package.json +1 -1
- /package/dist/{chunk-TDDHCW5S.js.map → chunk-GPNPMKVZ.js.map} +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// src/schemas/font-catalog.ts
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
var SAFE_FONTS = [
|
|
4
|
+
"Arial",
|
|
5
|
+
"Calibri",
|
|
6
|
+
"Cambria",
|
|
7
|
+
"Consolas",
|
|
8
|
+
"Courier New",
|
|
9
|
+
"Georgia",
|
|
10
|
+
"Segoe UI",
|
|
11
|
+
"Tahoma",
|
|
12
|
+
"Times New Roman",
|
|
13
|
+
"Trebuchet MS",
|
|
14
|
+
"Verdana",
|
|
15
|
+
"Helvetica",
|
|
16
|
+
"Helvetica Neue",
|
|
17
|
+
"Menlo",
|
|
18
|
+
"Monaco"
|
|
19
|
+
];
|
|
20
|
+
function isSafeFont(name) {
|
|
21
|
+
const lower = name.toLowerCase();
|
|
22
|
+
return SAFE_FONTS.some((f) => f.toLowerCase() === lower);
|
|
23
|
+
}
|
|
24
|
+
var FontFamilyNameSchema = Type.String({
|
|
25
|
+
description: "Font family name. Prefer a SAFE_FONTS entry (Arial, Calibri, Cambria, Consolas, Courier New, Georgia, Segoe UI, Tahoma, Times New Roman, Trebuchet MS, Verdana, Helvetica, Helvetica Neue, Menlo, Monaco) for zero-setup rendering. For any other font, register it in props.fontRegistry[] and reference it here by family. Unregistered non-safe names render with a host fallback.",
|
|
26
|
+
examples: ["Arial", "Calibri", "Georgia", "Inter", "Roboto"]
|
|
27
|
+
});
|
|
28
|
+
var FontWeightSchema = Type.Number({
|
|
29
|
+
minimum: 100,
|
|
30
|
+
maximum: 900,
|
|
31
|
+
description: "OpenType weight (100 thin ... 900 black). Default 400."
|
|
32
|
+
});
|
|
33
|
+
var FontItalicSchema = Type.Boolean({
|
|
34
|
+
description: "Whether this source is italic. Default false."
|
|
35
|
+
});
|
|
36
|
+
var SafeFontSourceSchema = Type.Object(
|
|
37
|
+
{
|
|
38
|
+
kind: Type.Literal("safe"),
|
|
39
|
+
family: Type.String({
|
|
40
|
+
description: "A SAFE_FONTS name \u2014 installed with Office."
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
additionalProperties: false,
|
|
45
|
+
description: "Office-installed font \u2014 no embedding"
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
var GoogleFontSourceSchema = Type.Object(
|
|
49
|
+
{
|
|
50
|
+
kind: Type.Literal("google"),
|
|
51
|
+
family: Type.String({
|
|
52
|
+
description: 'Exact Google Fonts family name (e.g. "Inter").'
|
|
53
|
+
}),
|
|
54
|
+
weights: Type.Optional(
|
|
55
|
+
Type.Array(FontWeightSchema, {
|
|
56
|
+
description: "Weights to fetch. Default [400, 700]."
|
|
57
|
+
})
|
|
58
|
+
),
|
|
59
|
+
italics: Type.Optional(
|
|
60
|
+
Type.Boolean({ description: "Include italic variants. Default false." })
|
|
61
|
+
)
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
additionalProperties: false,
|
|
65
|
+
description: "Google Fonts \u2014 auto-fetched and embedded"
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
var FileFontSourceSchema = Type.Object(
|
|
69
|
+
{
|
|
70
|
+
kind: Type.Literal("file"),
|
|
71
|
+
path: Type.String({
|
|
72
|
+
description: "Path to a .ttf/.otf file. Relative paths are resolved against the JSON document file."
|
|
73
|
+
}),
|
|
74
|
+
weight: Type.Optional(FontWeightSchema),
|
|
75
|
+
italic: Type.Optional(FontItalicSchema)
|
|
76
|
+
},
|
|
77
|
+
{ additionalProperties: false, description: "Local font file to embed" }
|
|
78
|
+
);
|
|
79
|
+
var UrlFontSourceSchema = Type.Object(
|
|
80
|
+
{
|
|
81
|
+
kind: Type.Literal("url"),
|
|
82
|
+
url: Type.String({
|
|
83
|
+
description: "HTTPS URL of a TTF or OTF file."
|
|
84
|
+
}),
|
|
85
|
+
weight: Type.Optional(FontWeightSchema),
|
|
86
|
+
italic: Type.Optional(FontItalicSchema)
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
additionalProperties: false,
|
|
90
|
+
description: "Direct TTF/OTF URL (non-Google CDN)"
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
var VariableFontSourceSchema = Type.Object(
|
|
94
|
+
{
|
|
95
|
+
kind: Type.Literal("variable"),
|
|
96
|
+
url: Type.String({
|
|
97
|
+
description: "HTTPS URL of a variable TTF (`fvar` axis table required)."
|
|
98
|
+
}),
|
|
99
|
+
weight: FontWeightSchema,
|
|
100
|
+
italic: Type.Optional(FontItalicSchema),
|
|
101
|
+
axes: Type.Optional(
|
|
102
|
+
Type.Record(Type.String(), Type.Number(), {
|
|
103
|
+
description: "Additional axis pin values (e.g. `{ ital: 1, opsz: 14 }`) merged on top of the derived `wght` pin. Uncommon \u2014 the `weight` field is usually enough."
|
|
104
|
+
})
|
|
105
|
+
)
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
additionalProperties: false,
|
|
109
|
+
description: "Variable-font instancer. The fetcher pins `wght` to `weight` (plus any `axes` overrides) and emits a clean static TTF, bypassing upstream distributions that collapse multiple static weights onto the same glyph geometry."
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
var DataFontSourceSchema = Type.Object(
|
|
113
|
+
{
|
|
114
|
+
kind: Type.Literal("data"),
|
|
115
|
+
data: Type.String({
|
|
116
|
+
description: "Base64-encoded TTF/OTF or data: URL (data:font/ttf;base64,...). Makes the JSON self-contained at the cost of size."
|
|
117
|
+
}),
|
|
118
|
+
weight: Type.Optional(FontWeightSchema),
|
|
119
|
+
italic: Type.Optional(FontItalicSchema)
|
|
120
|
+
},
|
|
121
|
+
{ additionalProperties: false, description: "Inline base64 font \u2014 portable" }
|
|
122
|
+
);
|
|
123
|
+
var FontSourceSchema = Type.Union(
|
|
124
|
+
[
|
|
125
|
+
SafeFontSourceSchema,
|
|
126
|
+
GoogleFontSourceSchema,
|
|
127
|
+
FileFontSourceSchema,
|
|
128
|
+
DataFontSourceSchema,
|
|
129
|
+
UrlFontSourceSchema,
|
|
130
|
+
VariableFontSourceSchema
|
|
131
|
+
],
|
|
132
|
+
{
|
|
133
|
+
description: 'A single font variant source. Use kind:"safe" for installed fonts, kind:"google" for Google Fonts, kind:"file" for local files, kind:"data" for base64, kind:"url" for direct HTTPS TTF/OTF URLs, kind:"variable" to instance a variable TTF at a specific weight.'
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
var FontCategorySchema = Type.Union(
|
|
137
|
+
[
|
|
138
|
+
Type.Literal("sans"),
|
|
139
|
+
Type.Literal("serif"),
|
|
140
|
+
Type.Literal("mono"),
|
|
141
|
+
Type.Literal("display"),
|
|
142
|
+
Type.Literal("handwriting")
|
|
143
|
+
],
|
|
144
|
+
{ description: "Broad category used for fallback selection" }
|
|
145
|
+
);
|
|
146
|
+
var FontRegistryEntrySchema = Type.Object(
|
|
147
|
+
{
|
|
148
|
+
id: Type.String({
|
|
149
|
+
description: 'Registry key. By convention, match the display family name ("Inter", "Roboto Slab").'
|
|
150
|
+
}),
|
|
151
|
+
family: Type.String({
|
|
152
|
+
description: "Display family used in font.family / fontFace / theme.fonts.*. Usually identical to id."
|
|
153
|
+
}),
|
|
154
|
+
category: Type.Optional(FontCategorySchema),
|
|
155
|
+
sources: Type.Array(FontSourceSchema, {
|
|
156
|
+
minItems: 1,
|
|
157
|
+
description: "One or more weight/style variants. List at least a regular (weight 400, italic false)."
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
additionalProperties: false,
|
|
162
|
+
description: "A font registered for this document. Referenced by family from font.family, fontFace, and theme.fonts.*."
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
var FontRegistrySchema = Type.Array(FontRegistryEntrySchema, {
|
|
166
|
+
description: "Document-scoped font registry. Every non-safe font used in this document must be registered here."
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
SAFE_FONTS,
|
|
171
|
+
isSafeFont,
|
|
172
|
+
FontFamilyNameSchema,
|
|
173
|
+
FontSourceSchema,
|
|
174
|
+
FontRegistryEntrySchema,
|
|
175
|
+
FontRegistrySchema
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=chunk-6KUQYVPT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/font-catalog.ts"],"sourcesContent":["/**\n * Font catalog + registry schemas.\n *\n * Shared by DOCX and PPTX pipelines. Defines:\n * - SAFE_FONTS: Office-safe font names (installed on Windows/macOS with Office).\n * - FontFamilyNameSchema: free-form string for `font.family` / `fontFace`, with LLM-facing guidance.\n * - FontSourceSchema: one binary variant (safe | google | file | data).\n * - FontRegistryEntrySchema / FontRegistrySchema: document-scoped font registry.\n */\n\nimport { Type, Static } from '@sinclair/typebox';\n\n/**\n * Fonts pre-installed with Microsoft Office on Windows + macOS.\n * Using one of these requires no registration and no embedding.\n */\nexport const SAFE_FONTS = [\n 'Arial',\n 'Calibri',\n 'Cambria',\n 'Consolas',\n 'Courier New',\n 'Georgia',\n 'Segoe UI',\n 'Tahoma',\n 'Times New Roman',\n 'Trebuchet MS',\n 'Verdana',\n 'Helvetica',\n 'Helvetica Neue',\n 'Menlo',\n 'Monaco',\n] as const;\n\nexport type SafeFontName = (typeof SAFE_FONTS)[number];\n\n/** Case-insensitive membership test against SAFE_FONTS. */\nexport function isSafeFont(name: string): boolean {\n const lower = name.toLowerCase();\n return SAFE_FONTS.some((f) => f.toLowerCase() === lower);\n}\n\n/**\n * Font family name used in `font.family` / `fontFace`.\n *\n * Stays a free-form string so users can reference custom or Google fonts.\n * Description + examples guide LLMs and JSON Schema consumers toward SAFE_FONTS.\n */\nexport const FontFamilyNameSchema = Type.String({\n description:\n 'Font family name. Prefer a SAFE_FONTS entry (Arial, Calibri, Cambria, Consolas, Courier New, Georgia, Segoe UI, Tahoma, Times New Roman, Trebuchet MS, Verdana, Helvetica, Helvetica Neue, Menlo, Monaco) for zero-setup rendering. For any other font, register it in props.fontRegistry[] and reference it here by family. Unregistered non-safe names render with a host fallback.',\n examples: ['Arial', 'Calibri', 'Georgia', 'Inter', 'Roboto'],\n});\n\n// ----------------------------------------------------------------------------\n// Font sources — one weight/style variant\n// ----------------------------------------------------------------------------\n\nconst FontWeightSchema = Type.Number({\n minimum: 100,\n maximum: 900,\n description: 'OpenType weight (100 thin ... 900 black). Default 400.',\n});\n\nconst FontItalicSchema = Type.Boolean({\n description: 'Whether this source is italic. Default false.',\n});\n\n/** Safe reference — no embedding needed. */\nconst SafeFontSourceSchema = Type.Object(\n {\n kind: Type.Literal('safe'),\n family: Type.String({\n description: 'A SAFE_FONTS name — installed with Office.',\n }),\n },\n {\n additionalProperties: false,\n description: 'Office-installed font — no embedding',\n }\n);\n\n/** Google Fonts — fetched and embedded at generate time. */\nconst GoogleFontSourceSchema = Type.Object(\n {\n kind: Type.Literal('google'),\n family: Type.String({\n description: 'Exact Google Fonts family name (e.g. \"Inter\").',\n }),\n weights: Type.Optional(\n Type.Array(FontWeightSchema, {\n description: 'Weights to fetch. Default [400, 700].',\n })\n ),\n italics: Type.Optional(\n Type.Boolean({ description: 'Include italic variants. Default false.' })\n ),\n },\n {\n additionalProperties: false,\n description: 'Google Fonts — auto-fetched and embedded',\n }\n);\n\n/** Local TTF/OTF file — resolved relative to the JSON file, or absolute. */\nconst FileFontSourceSchema = Type.Object(\n {\n kind: Type.Literal('file'),\n path: Type.String({\n description:\n 'Path to a .ttf/.otf file. Relative paths are resolved against the JSON document file.',\n }),\n weight: Type.Optional(FontWeightSchema),\n italic: Type.Optional(FontItalicSchema),\n },\n { additionalProperties: false, description: 'Local font file to embed' }\n);\n\n/**\n * Direct URL to a TTF/OTF. Used to bypass Google Fonts redistribution for\n * families with known metadata defects — e.g. rsms/inter hosted on jsDelivr.\n * A single URL fetches one variant; multiple URLs build a multi-weight family.\n */\nconst UrlFontSourceSchema = Type.Object(\n {\n kind: Type.Literal('url'),\n url: Type.String({\n description: 'HTTPS URL of a TTF or OTF file.',\n }),\n weight: Type.Optional(FontWeightSchema),\n italic: Type.Optional(FontItalicSchema),\n },\n {\n additionalProperties: false,\n description: 'Direct TTF/OTF URL (non-Google CDN)',\n }\n);\n\n/**\n * Variable-font-instanced variant. Points at a variable TTF URL plus a\n * target weight (and optional additional `axes` pins); the fetcher\n * downloads the variable TTF once (disk-cached) and uses harfbuzz to pin\n * the `wght` axis (plus any additional axes) to produce a clean static\n * TTF for embedding.\n *\n * Used to escape Google Fonts' lossy per-weight static generation — e.g.\n * Google ships Inter Thin and Inter ExtraLight as near-identical glyph\n * files (both sourced around wght=250), but the upstream variable Inter\n * produces properly distinct static instances when pinned precisely at\n * wght=100 vs wght=200.\n */\nconst VariableFontSourceSchema = Type.Object(\n {\n kind: Type.Literal('variable'),\n url: Type.String({\n description: 'HTTPS URL of a variable TTF (`fvar` axis table required).',\n }),\n weight: FontWeightSchema,\n italic: Type.Optional(FontItalicSchema),\n axes: Type.Optional(\n Type.Record(Type.String(), Type.Number(), {\n description:\n 'Additional axis pin values (e.g. `{ ital: 1, opsz: 14 }`) merged on top of the derived `wght` pin. Uncommon — the `weight` field is usually enough.',\n })\n ),\n },\n {\n additionalProperties: false,\n description:\n 'Variable-font instancer. The fetcher pins `wght` to `weight` (plus any `axes` overrides) and emits a clean static TTF, bypassing upstream distributions that collapse multiple static weights onto the same glyph geometry.',\n }\n);\n\n/** Inline base64 / data-URL — self-contained JSON. */\nconst DataFontSourceSchema = Type.Object(\n {\n kind: Type.Literal('data'),\n data: Type.String({\n description:\n 'Base64-encoded TTF/OTF or data: URL (data:font/ttf;base64,...). Makes the JSON self-contained at the cost of size.',\n }),\n weight: Type.Optional(FontWeightSchema),\n italic: Type.Optional(FontItalicSchema),\n },\n { additionalProperties: false, description: 'Inline base64 font — portable' }\n);\n\n/**\n * One weight/style variant backing a font registry entry.\n *\n * Kinds:\n * - safe: references an Office-installed font; no embedding.\n * - google: Google Fonts family; fetched and embedded at generate time.\n * - file: local .ttf/.otf read from disk.\n * - data: inline base64, makes JSON self-contained.\n */\nexport const FontSourceSchema = Type.Union(\n [\n SafeFontSourceSchema,\n GoogleFontSourceSchema,\n FileFontSourceSchema,\n DataFontSourceSchema,\n UrlFontSourceSchema,\n VariableFontSourceSchema,\n ],\n {\n description:\n 'A single font variant source. Use kind:\"safe\" for installed fonts, kind:\"google\" for Google Fonts, kind:\"file\" for local files, kind:\"data\" for base64, kind:\"url\" for direct HTTPS TTF/OTF URLs, kind:\"variable\" to instance a variable TTF at a specific weight.',\n }\n);\n\nexport type FontSource = Static<typeof FontSourceSchema>;\n\n// ----------------------------------------------------------------------------\n// Font registry entry\n// ----------------------------------------------------------------------------\n\nconst FontCategorySchema = Type.Union(\n [\n Type.Literal('sans'),\n Type.Literal('serif'),\n Type.Literal('mono'),\n Type.Literal('display'),\n Type.Literal('handwriting'),\n ],\n { description: 'Broad category used for fallback selection' }\n);\n\nexport const FontRegistryEntrySchema = Type.Object(\n {\n id: Type.String({\n description:\n 'Registry key. By convention, match the display family name (\"Inter\", \"Roboto Slab\").',\n }),\n family: Type.String({\n description:\n 'Display family used in font.family / fontFace / theme.fonts.*. Usually identical to id.',\n }),\n category: Type.Optional(FontCategorySchema),\n sources: Type.Array(FontSourceSchema, {\n minItems: 1,\n description:\n 'One or more weight/style variants. List at least a regular (weight 400, italic false).',\n }),\n },\n {\n additionalProperties: false,\n description:\n 'A font registered for this document. Referenced by family from font.family, fontFace, and theme.fonts.*.',\n }\n);\n\nexport type FontRegistryEntry = Static<typeof FontRegistryEntrySchema>;\n\n/**\n * Document-scoped font registry.\n *\n * Ships with the JSON — no runtime side-channel needed for the common case.\n * Every font name used in font.family / fontFace / theme.fonts.* that isn't\n * in SAFE_FONTS must resolve to an entry here (by family) or tooling warns.\n */\nexport const FontRegistrySchema = Type.Array(FontRegistryEntrySchema, {\n description:\n 'Document-scoped font registry. Every non-safe font used in this document must be registered here.',\n});\n\nexport type FontRegistryDefinition = Static<typeof FontRegistrySchema>;\n"],"mappings":";AAUA,SAAS,YAAoB;AAMtB,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,SAAS,WAAW,MAAuB;AAChD,QAAM,QAAQ,KAAK,YAAY;AAC/B,SAAO,WAAW,KAAK,CAAC,MAAM,EAAE,YAAY,MAAM,KAAK;AACzD;AAQO,IAAM,uBAAuB,KAAK,OAAO;AAAA,EAC9C,aACE;AAAA,EACF,UAAU,CAAC,SAAS,WAAW,WAAW,SAAS,QAAQ;AAC7D,CAAC;AAMD,IAAM,mBAAmB,KAAK,OAAO;AAAA,EACnC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,aAAa;AACf,CAAC;AAED,IAAM,mBAAmB,KAAK,QAAQ;AAAA,EACpC,aAAa;AACf,CAAC;AAGD,IAAM,uBAAuB,KAAK;AAAA,EAChC;AAAA,IACE,MAAM,KAAK,QAAQ,MAAM;AAAA,IACzB,QAAQ,KAAK,OAAO;AAAA,MAClB,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AAAA,EACA;AAAA,IACE,sBAAsB;AAAA,IACtB,aAAa;AA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qBAAqB,KAAK,MAAM,yBAAyB;AAAA,EACpE,aACE;AACJ,CAAC;","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isValidSemver,
|
|
3
|
-
latestVersion
|
|
4
|
-
} from "./chunk-244MHDOZ.js";
|
|
5
1
|
import {
|
|
6
2
|
formatErrorSummary,
|
|
7
3
|
transformValueErrors
|
|
8
4
|
} from "./chunk-ZKD5BAMU.js";
|
|
5
|
+
import {
|
|
6
|
+
isValidSemver,
|
|
7
|
+
latestVersion
|
|
8
|
+
} from "./chunk-244MHDOZ.js";
|
|
9
9
|
|
|
10
10
|
// src/plugin/createComponent.ts
|
|
11
11
|
function createVersion(version) {
|
|
@@ -198,4 +198,4 @@ export {
|
|
|
198
198
|
isValidationSuccess,
|
|
199
199
|
getValidationSummary
|
|
200
200
|
};
|
|
201
|
-
//# sourceMappingURL=chunk-
|
|
201
|
+
//# sourceMappingURL=chunk-GPNPMKVZ.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -517,6 +517,43 @@ interface ApplyExportModeResult<D, T> {
|
|
|
517
517
|
*/
|
|
518
518
|
declare function applyExportMode<D, T>(input: ApplyExportModeInput<D, T>): ApplyExportModeResult<D, T>;
|
|
519
519
|
|
|
520
|
+
/**
|
|
521
|
+
* Default series-color tokens for charts. Single source of truth for every
|
|
522
|
+
* format: the PPTX `chart` and `highcharts` components and the DOCX
|
|
523
|
+
* `highcharts` component all resolve this list, in this order, against the
|
|
524
|
+
* active theme when the author sets no explicit colors. Both theme schemas
|
|
525
|
+
* declare all six tokens (accent4-6 optional in each), so a theme that fills
|
|
526
|
+
* every slot produces the same palette in a deck and in a document.
|
|
527
|
+
*
|
|
528
|
+
* Slots the theme leaves unset are skipped in both formats: the implicit
|
|
529
|
+
* palette shrinks and the chart library cycles the shorter list rather than
|
|
530
|
+
* repeating `primary` for every empty slot. A theme carrying only
|
|
531
|
+
* primary/secondary/accent — which is what the bundled DOCX themes carry —
|
|
532
|
+
* therefore paints series 4+ identically in a deck and in a document.
|
|
533
|
+
*
|
|
534
|
+
* Skipping compacts holes: a theme defining accent5 but not accent4 yields
|
|
535
|
+
* [primary, secondary, accent, accent5], so accent5 paints series 4. The list
|
|
536
|
+
* is a preference-ordered pool of candidate colors, not fixed per-series slots,
|
|
537
|
+
* so keeping a color the theme did define beats dropping or duplicating one.
|
|
538
|
+
*
|
|
539
|
+
* A slot may also hold another token's name (`"accent4": "primary"`) — both
|
|
540
|
+
* theme schemas allow it — and both formats walk that reference to hex before
|
|
541
|
+
* using it, so a chained slot lands on the same color in a deck as in a
|
|
542
|
+
* document. A slot whose value reaches no hex (`"accent4": "nonsense"`, or a
|
|
543
|
+
* reference cycle) is dropped from the implicit palette in both formats rather
|
|
544
|
+
* than emitted verbatim: PowerPoint and Highcharts both answer an unparseable
|
|
545
|
+
* color with silent black. Parity here covers the token names the two schemas
|
|
546
|
+
* share; each format also has private color keys (DOCX `textSecondary`, PPTX
|
|
547
|
+
* `text2`) that only resolve in their own format.
|
|
548
|
+
*
|
|
549
|
+
* Only the implicit palette skips. An author who names a token explicitly
|
|
550
|
+
* (PPTX `chartColors: ['accent4']`) still gets the `primary` fallback and a
|
|
551
|
+
* warning — naming an undefined token is an authoring error and stays loud.
|
|
552
|
+
* PPTX warns THEME_COLOR_FALLBACK for an unset slot and UNKNOWN_COLOR for one
|
|
553
|
+
* holding an unresolvable value; DOCX throws.
|
|
554
|
+
*/
|
|
555
|
+
declare const DEFAULT_CHART_THEME_COLORS: string[];
|
|
556
|
+
|
|
520
557
|
/**
|
|
521
558
|
* Deep Merge Utilities
|
|
522
559
|
* Generic deep-merge helpers used by both docx and pptx
|
|
@@ -530,4 +567,4 @@ declare function applyExportMode<D, T>(input: ApplyExportModeInput<D, T>): Apply
|
|
|
530
567
|
*/
|
|
531
568
|
declare function mergeWithDefaults<T>(userConfig: T, themeDefaults: Partial<T>): T;
|
|
532
569
|
|
|
533
|
-
export { DEFAULT_VISUAL_DPI, type FontIssueCode, FontRegistry, FontRegistryEntry, type FontRegistryInput, type FontResolutionIssue, FontRuntimeOpts, type FontSubstitution, type FontValidationInput, type FontValidationResult, type HighchartsHeaders, type HighchartsHeadersResolver, type HighchartsServiceConfig, MAX_VISUAL_DPI, MIN_VISUAL_DPI, POPULAR_GOOGLE_FONTS, type PopularGoogleFont, type PptxRasterizeRequest, type PptxRasterizeResult, type PptxRasterizer, type PptxServiceConfig, type PptxServiceHeaders, type PptxServiceHeadersResolver, ResolvedFont, ResolvedFontSource, type ServicesConfig, type SynthesizedFamily, UPSTREAM_OVERRIDES, type UpstreamOverride, type UpstreamVariant, WEIGHT_LABELS, applyExportMode, applyFontSubstitution, buildDefaultSubstitutionMap, clampVisualDpi, collectFontNamesFromDocx, collectFontNamesFromPptx, defaultSubstituteFor, detectFontFormat, fetchGoogleFontSources, getUpstreamOverride, mergeWithDefaults, rewriteFontFamilyName, scopedThemeName, synthesizeFamilyName, validateFontReferences };
|
|
570
|
+
export { DEFAULT_CHART_THEME_COLORS, DEFAULT_VISUAL_DPI, type FontIssueCode, FontRegistry, FontRegistryEntry, type FontRegistryInput, type FontResolutionIssue, FontRuntimeOpts, type FontSubstitution, type FontValidationInput, type FontValidationResult, type HighchartsHeaders, type HighchartsHeadersResolver, type HighchartsServiceConfig, MAX_VISUAL_DPI, MIN_VISUAL_DPI, POPULAR_GOOGLE_FONTS, type PopularGoogleFont, type PptxRasterizeRequest, type PptxRasterizeResult, type PptxRasterizer, type PptxServiceConfig, type PptxServiceHeaders, type PptxServiceHeadersResolver, ResolvedFont, ResolvedFontSource, type ServicesConfig, type SynthesizedFamily, UPSTREAM_OVERRIDES, type UpstreamOverride, type UpstreamVariant, WEIGHT_LABELS, applyExportMode, applyFontSubstitution, buildDefaultSubstitutionMap, clampVisualDpi, collectFontNamesFromDocx, collectFontNamesFromPptx, defaultSubstituteFor, detectFontFormat, fetchGoogleFontSources, getUpstreamOverride, mergeWithDefaults, rewriteFontFamilyName, scopedThemeName, synthesizeFamilyName, validateFontReferences };
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,6 @@ import {
|
|
|
2
2
|
detectFontFormat,
|
|
3
3
|
isAllowedFontUrl
|
|
4
4
|
} from "./chunk-CP2I5NPP.js";
|
|
5
|
-
import {
|
|
6
|
-
convertToJsonSchema,
|
|
7
|
-
createComponentSchema,
|
|
8
|
-
createComponentSchemaObject,
|
|
9
|
-
exportSchemaToFile,
|
|
10
|
-
fixSchemaReferences
|
|
11
|
-
} from "./chunk-5J43F4XD.js";
|
|
12
5
|
import {
|
|
13
6
|
ComponentValidationError,
|
|
14
7
|
DuplicateComponentError,
|
|
@@ -19,13 +12,7 @@ import {
|
|
|
19
12
|
isValidationSuccess,
|
|
20
13
|
resolveComponentVersion,
|
|
21
14
|
validateCustomComponentProps
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import {
|
|
24
|
-
compareSemver,
|
|
25
|
-
isValidSemver,
|
|
26
|
-
latestVersion,
|
|
27
|
-
parseSemver
|
|
28
|
-
} from "./chunk-244MHDOZ.js";
|
|
15
|
+
} from "./chunk-GPNPMKVZ.js";
|
|
29
16
|
import {
|
|
30
17
|
DEFAULT_ERROR_CONFIG,
|
|
31
18
|
ERROR_EMOJIS,
|
|
@@ -46,6 +33,27 @@ import {
|
|
|
46
33
|
transformValueError,
|
|
47
34
|
transformValueErrors
|
|
48
35
|
} from "./chunk-ZKD5BAMU.js";
|
|
36
|
+
import {
|
|
37
|
+
convertToJsonSchema,
|
|
38
|
+
createComponentSchema,
|
|
39
|
+
createComponentSchemaObject,
|
|
40
|
+
exportSchemaToFile,
|
|
41
|
+
fixSchemaReferences
|
|
42
|
+
} from "./chunk-5J43F4XD.js";
|
|
43
|
+
import {
|
|
44
|
+
FontFamilyNameSchema,
|
|
45
|
+
FontRegistryEntrySchema,
|
|
46
|
+
FontRegistrySchema,
|
|
47
|
+
FontSourceSchema,
|
|
48
|
+
SAFE_FONTS,
|
|
49
|
+
isSafeFont
|
|
50
|
+
} from "./chunk-6KUQYVPT.js";
|
|
51
|
+
import {
|
|
52
|
+
compareSemver,
|
|
53
|
+
isValidSemver,
|
|
54
|
+
latestVersion,
|
|
55
|
+
parseSemver
|
|
56
|
+
} from "./chunk-244MHDOZ.js";
|
|
49
57
|
|
|
50
58
|
// src/types/services.ts
|
|
51
59
|
var DEFAULT_VISUAL_DPI = 200;
|
|
@@ -57,174 +65,6 @@ function clampVisualDpi(dpi) {
|
|
|
57
65
|
return Math.min(MAX_VISUAL_DPI, Math.max(MIN_VISUAL_DPI, Math.round(dpi)));
|
|
58
66
|
}
|
|
59
67
|
|
|
60
|
-
// src/schemas/font-catalog.ts
|
|
61
|
-
import { Type } from "@sinclair/typebox";
|
|
62
|
-
var SAFE_FONTS = [
|
|
63
|
-
"Arial",
|
|
64
|
-
"Calibri",
|
|
65
|
-
"Cambria",
|
|
66
|
-
"Consolas",
|
|
67
|
-
"Courier New",
|
|
68
|
-
"Georgia",
|
|
69
|
-
"Segoe UI",
|
|
70
|
-
"Tahoma",
|
|
71
|
-
"Times New Roman",
|
|
72
|
-
"Trebuchet MS",
|
|
73
|
-
"Verdana",
|
|
74
|
-
"Helvetica",
|
|
75
|
-
"Helvetica Neue",
|
|
76
|
-
"Menlo",
|
|
77
|
-
"Monaco"
|
|
78
|
-
];
|
|
79
|
-
function isSafeFont(name) {
|
|
80
|
-
const lower = name.toLowerCase();
|
|
81
|
-
return SAFE_FONTS.some((f) => f.toLowerCase() === lower);
|
|
82
|
-
}
|
|
83
|
-
var FontFamilyNameSchema = Type.String({
|
|
84
|
-
description: "Font family name. Prefer a SAFE_FONTS entry (Arial, Calibri, Cambria, Consolas, Courier New, Georgia, Segoe UI, Tahoma, Times New Roman, Trebuchet MS, Verdana, Helvetica, Helvetica Neue, Menlo, Monaco) for zero-setup rendering. For any other font, register it in props.fontRegistry[] and reference it here by family. Unregistered non-safe names render with a host fallback.",
|
|
85
|
-
examples: ["Arial", "Calibri", "Georgia", "Inter", "Roboto"]
|
|
86
|
-
});
|
|
87
|
-
var FontWeightSchema = Type.Number({
|
|
88
|
-
minimum: 100,
|
|
89
|
-
maximum: 900,
|
|
90
|
-
description: "OpenType weight (100 thin ... 900 black). Default 400."
|
|
91
|
-
});
|
|
92
|
-
var FontItalicSchema = Type.Boolean({
|
|
93
|
-
description: "Whether this source is italic. Default false."
|
|
94
|
-
});
|
|
95
|
-
var SafeFontSourceSchema = Type.Object(
|
|
96
|
-
{
|
|
97
|
-
kind: Type.Literal("safe"),
|
|
98
|
-
family: Type.String({
|
|
99
|
-
description: "A SAFE_FONTS name \u2014 installed with Office."
|
|
100
|
-
})
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
additionalProperties: false,
|
|
104
|
-
description: "Office-installed font \u2014 no embedding"
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
var GoogleFontSourceSchema = Type.Object(
|
|
108
|
-
{
|
|
109
|
-
kind: Type.Literal("google"),
|
|
110
|
-
family: Type.String({
|
|
111
|
-
description: 'Exact Google Fonts family name (e.g. "Inter").'
|
|
112
|
-
}),
|
|
113
|
-
weights: Type.Optional(
|
|
114
|
-
Type.Array(FontWeightSchema, {
|
|
115
|
-
description: "Weights to fetch. Default [400, 700]."
|
|
116
|
-
})
|
|
117
|
-
),
|
|
118
|
-
italics: Type.Optional(
|
|
119
|
-
Type.Boolean({ description: "Include italic variants. Default false." })
|
|
120
|
-
)
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
additionalProperties: false,
|
|
124
|
-
description: "Google Fonts \u2014 auto-fetched and embedded"
|
|
125
|
-
}
|
|
126
|
-
);
|
|
127
|
-
var FileFontSourceSchema = Type.Object(
|
|
128
|
-
{
|
|
129
|
-
kind: Type.Literal("file"),
|
|
130
|
-
path: Type.String({
|
|
131
|
-
description: "Path to a .ttf/.otf file. Relative paths are resolved against the JSON document file."
|
|
132
|
-
}),
|
|
133
|
-
weight: Type.Optional(FontWeightSchema),
|
|
134
|
-
italic: Type.Optional(FontItalicSchema)
|
|
135
|
-
},
|
|
136
|
-
{ additionalProperties: false, description: "Local font file to embed" }
|
|
137
|
-
);
|
|
138
|
-
var UrlFontSourceSchema = Type.Object(
|
|
139
|
-
{
|
|
140
|
-
kind: Type.Literal("url"),
|
|
141
|
-
url: Type.String({
|
|
142
|
-
description: "HTTPS URL of a TTF or OTF file."
|
|
143
|
-
}),
|
|
144
|
-
weight: Type.Optional(FontWeightSchema),
|
|
145
|
-
italic: Type.Optional(FontItalicSchema)
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
additionalProperties: false,
|
|
149
|
-
description: "Direct TTF/OTF URL (non-Google CDN)"
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
var VariableFontSourceSchema = Type.Object(
|
|
153
|
-
{
|
|
154
|
-
kind: Type.Literal("variable"),
|
|
155
|
-
url: Type.String({
|
|
156
|
-
description: "HTTPS URL of a variable TTF (`fvar` axis table required)."
|
|
157
|
-
}),
|
|
158
|
-
weight: FontWeightSchema,
|
|
159
|
-
italic: Type.Optional(FontItalicSchema),
|
|
160
|
-
axes: Type.Optional(
|
|
161
|
-
Type.Record(Type.String(), Type.Number(), {
|
|
162
|
-
description: "Additional axis pin values (e.g. `{ ital: 1, opsz: 14 }`) merged on top of the derived `wght` pin. Uncommon \u2014 the `weight` field is usually enough."
|
|
163
|
-
})
|
|
164
|
-
)
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
additionalProperties: false,
|
|
168
|
-
description: "Variable-font instancer. The fetcher pins `wght` to `weight` (plus any `axes` overrides) and emits a clean static TTF, bypassing upstream distributions that collapse multiple static weights onto the same glyph geometry."
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
var DataFontSourceSchema = Type.Object(
|
|
172
|
-
{
|
|
173
|
-
kind: Type.Literal("data"),
|
|
174
|
-
data: Type.String({
|
|
175
|
-
description: "Base64-encoded TTF/OTF or data: URL (data:font/ttf;base64,...). Makes the JSON self-contained at the cost of size."
|
|
176
|
-
}),
|
|
177
|
-
weight: Type.Optional(FontWeightSchema),
|
|
178
|
-
italic: Type.Optional(FontItalicSchema)
|
|
179
|
-
},
|
|
180
|
-
{ additionalProperties: false, description: "Inline base64 font \u2014 portable" }
|
|
181
|
-
);
|
|
182
|
-
var FontSourceSchema = Type.Union(
|
|
183
|
-
[
|
|
184
|
-
SafeFontSourceSchema,
|
|
185
|
-
GoogleFontSourceSchema,
|
|
186
|
-
FileFontSourceSchema,
|
|
187
|
-
DataFontSourceSchema,
|
|
188
|
-
UrlFontSourceSchema,
|
|
189
|
-
VariableFontSourceSchema
|
|
190
|
-
],
|
|
191
|
-
{
|
|
192
|
-
description: 'A single font variant source. Use kind:"safe" for installed fonts, kind:"google" for Google Fonts, kind:"file" for local files, kind:"data" for base64, kind:"url" for direct HTTPS TTF/OTF URLs, kind:"variable" to instance a variable TTF at a specific weight.'
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
var FontCategorySchema = Type.Union(
|
|
196
|
-
[
|
|
197
|
-
Type.Literal("sans"),
|
|
198
|
-
Type.Literal("serif"),
|
|
199
|
-
Type.Literal("mono"),
|
|
200
|
-
Type.Literal("display"),
|
|
201
|
-
Type.Literal("handwriting")
|
|
202
|
-
],
|
|
203
|
-
{ description: "Broad category used for fallback selection" }
|
|
204
|
-
);
|
|
205
|
-
var FontRegistryEntrySchema = Type.Object(
|
|
206
|
-
{
|
|
207
|
-
id: Type.String({
|
|
208
|
-
description: 'Registry key. By convention, match the display family name ("Inter", "Roboto Slab").'
|
|
209
|
-
}),
|
|
210
|
-
family: Type.String({
|
|
211
|
-
description: "Display family used in font.family / fontFace / theme.fonts.*. Usually identical to id."
|
|
212
|
-
}),
|
|
213
|
-
category: Type.Optional(FontCategorySchema),
|
|
214
|
-
sources: Type.Array(FontSourceSchema, {
|
|
215
|
-
minItems: 1,
|
|
216
|
-
description: "One or more weight/style variants. List at least a regular (weight 400, italic false)."
|
|
217
|
-
})
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
additionalProperties: false,
|
|
221
|
-
description: "A font registered for this document. Referenced by family from font.family, fontFace, and theme.fonts.*."
|
|
222
|
-
}
|
|
223
|
-
);
|
|
224
|
-
var FontRegistrySchema = Type.Array(FontRegistryEntrySchema, {
|
|
225
|
-
description: "Document-scoped font registry. Every non-safe font used in this document must be registered here."
|
|
226
|
-
});
|
|
227
|
-
|
|
228
68
|
// src/fonts/collect.ts
|
|
229
69
|
var FONT_NAME_KEYS = /* @__PURE__ */ new Set([
|
|
230
70
|
"family",
|
|
@@ -1516,6 +1356,16 @@ function applyExportMode(input) {
|
|
|
1516
1356
|
};
|
|
1517
1357
|
}
|
|
1518
1358
|
|
|
1359
|
+
// src/theme/chart-palette.ts
|
|
1360
|
+
var DEFAULT_CHART_THEME_COLORS = [
|
|
1361
|
+
"primary",
|
|
1362
|
+
"secondary",
|
|
1363
|
+
"accent",
|
|
1364
|
+
"accent4",
|
|
1365
|
+
"accent5",
|
|
1366
|
+
"accent6"
|
|
1367
|
+
];
|
|
1368
|
+
|
|
1519
1369
|
// src/utils/deepMerge.ts
|
|
1520
1370
|
function isObject(item) {
|
|
1521
1371
|
return item !== null && typeof item === "object" && !Array.isArray(item);
|
|
@@ -1542,6 +1392,7 @@ function mergeWithDefaults(userConfig, themeDefaults) {
|
|
|
1542
1392
|
}
|
|
1543
1393
|
export {
|
|
1544
1394
|
ComponentValidationError,
|
|
1395
|
+
DEFAULT_CHART_THEME_COLORS,
|
|
1545
1396
|
DEFAULT_ERROR_CONFIG,
|
|
1546
1397
|
DEFAULT_VISUAL_DPI,
|
|
1547
1398
|
DuplicateComponentError,
|