odf.js 1.0.0 → 1.2.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.cjs +1040 -0
- package/dist/index.d.cts +186 -1
- package/dist/index.d.ts +186 -1
- package/dist/index.js +1006 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -263,6 +263,8 @@ declare function encodePackage(pkg: Package): Uint8Array<ArrayBuffer>;
|
|
|
263
263
|
declare function parsePackage(bytes: Uint8Array<ArrayBuffer>): Package;
|
|
264
264
|
//#endregion
|
|
265
265
|
//#region src/package-io/write.d.ts
|
|
266
|
+
declare const MIMETYPE_PART = "mimetype";
|
|
267
|
+
declare const MANIFEST_PART = "META-INF/manifest.xml";
|
|
266
268
|
declare function serializePackage(pkg: Package): Uint8Array<ArrayBuffer>;
|
|
267
269
|
//#endregion
|
|
268
270
|
//#region src/xml/parse.d.ts
|
|
@@ -283,4 +285,187 @@ declare function zipPackage(entries: readonly (readonly [string, ZipEntry])[]):
|
|
|
283
285
|
declare function bytesToBase64(bytes: Uint8Array<ArrayBuffer>): string;
|
|
284
286
|
declare function base64ToBytes(b64: string): Uint8Array<ArrayBuffer>;
|
|
285
287
|
//#endregion
|
|
286
|
-
|
|
288
|
+
//#region src/ns.d.ts
|
|
289
|
+
declare const ODF_NAMESPACES: Readonly<{
|
|
290
|
+
office: "urn:oasis:names:tc:opendocument:xmlns:office:1.0";
|
|
291
|
+
style: "urn:oasis:names:tc:opendocument:xmlns:style:1.0";
|
|
292
|
+
text: "urn:oasis:names:tc:opendocument:xmlns:text:1.0";
|
|
293
|
+
table: "urn:oasis:names:tc:opendocument:xmlns:table:1.0";
|
|
294
|
+
draw: "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0";
|
|
295
|
+
fo: "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0";
|
|
296
|
+
svg: "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0";
|
|
297
|
+
xlink: "http://www.w3.org/1999/xlink";
|
|
298
|
+
dc: "http://purl.org/dc/elements/1.1/";
|
|
299
|
+
meta: "urn:oasis:names:tc:opendocument:xmlns:meta:1.0";
|
|
300
|
+
number: "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0";
|
|
301
|
+
chart: "urn:oasis:names:tc:opendocument:xmlns:chart:1.0";
|
|
302
|
+
dr3d: "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0";
|
|
303
|
+
math: "http://www.w3.org/1998/Math/MathML";
|
|
304
|
+
form: "urn:oasis:names:tc:opendocument:xmlns:form:1.0";
|
|
305
|
+
script: "urn:oasis:names:tc:opendocument:xmlns:script:1.0";
|
|
306
|
+
config: "urn:oasis:names:tc:opendocument:xmlns:config:1.0";
|
|
307
|
+
presentation: "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0";
|
|
308
|
+
smil: "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0";
|
|
309
|
+
anim: "urn:oasis:names:tc:opendocument:xmlns:animation:1.0";
|
|
310
|
+
xforms: "http://www.w3.org/2002/xforms";
|
|
311
|
+
xsd: "http://www.w3.org/2001/XMLSchema";
|
|
312
|
+
xsi: "http://www.w3.org/2001/XMLSchema-instance";
|
|
313
|
+
manifest: "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
|
|
314
|
+
}>;
|
|
315
|
+
type OdfNamespacePrefix = keyof typeof ODF_NAMESPACES;
|
|
316
|
+
declare function xmlnsAttributes(prefixes: readonly OdfNamespacePrefix[]): Record<string, string>;
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/media-type.d.ts
|
|
319
|
+
declare const ODF_MEDIA_TYPES: Readonly<{
|
|
320
|
+
odt: "application/vnd.oasis.opendocument.text";
|
|
321
|
+
ott: "application/vnd.oasis.opendocument.text-template";
|
|
322
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet";
|
|
323
|
+
ots: "application/vnd.oasis.opendocument.spreadsheet-template";
|
|
324
|
+
odp: "application/vnd.oasis.opendocument.presentation";
|
|
325
|
+
otp: "application/vnd.oasis.opendocument.presentation-template";
|
|
326
|
+
odg: "application/vnd.oasis.opendocument.graphics";
|
|
327
|
+
otg: "application/vnd.oasis.opendocument.graphics-template";
|
|
328
|
+
odf: "application/vnd.oasis.opendocument.formula";
|
|
329
|
+
otf: "application/vnd.oasis.opendocument.formula-template";
|
|
330
|
+
odm: "application/vnd.oasis.opendocument.text-master";
|
|
331
|
+
otm: "application/vnd.oasis.opendocument.text-master-template";
|
|
332
|
+
odb: "application/vnd.oasis.opendocument.base";
|
|
333
|
+
}>;
|
|
334
|
+
type OdfExtension = keyof typeof ODF_MEDIA_TYPES;
|
|
335
|
+
declare function mediaTypeForExtension(extension: string): string | undefined;
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/image/sniff.d.ts
|
|
338
|
+
type ImageFormat = 'png' | 'jpeg';
|
|
339
|
+
declare function sniffImageFormat(bytes: Uint8Array<ArrayBuffer>): ImageFormat | undefined;
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/mimetype.d.ts
|
|
342
|
+
declare function readMimetype(pkg: Package): string | undefined;
|
|
343
|
+
declare function writeMimetype(pkg: Package, mediaType: string): void;
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/xml/fragment.d.ts
|
|
346
|
+
declare function el(tag: string, attrs?: Record<string, string>, children?: XmlNode[]): XmlElement;
|
|
347
|
+
declare function txt(value: string): XmlText;
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/xml/entities.d.ts
|
|
350
|
+
declare function encodeXmlText(value: string): string;
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/manifest.d.ts
|
|
353
|
+
declare const ManifestEntrySchema: z.ZodObject<{
|
|
354
|
+
fullPath: z.ZodString;
|
|
355
|
+
mediaType: z.ZodString;
|
|
356
|
+
version: z.ZodOptional<z.ZodString>;
|
|
357
|
+
}, z.core.$strip>;
|
|
358
|
+
type ManifestEntry = z.infer<typeof ManifestEntrySchema>;
|
|
359
|
+
declare const ManifestSchema: z.ZodObject<{
|
|
360
|
+
version: z.ZodString;
|
|
361
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
362
|
+
fullPath: z.ZodString;
|
|
363
|
+
mediaType: z.ZodString;
|
|
364
|
+
version: z.ZodOptional<z.ZodString>;
|
|
365
|
+
}, z.core.$strip>>;
|
|
366
|
+
}, z.core.$strip>;
|
|
367
|
+
type Manifest = z.infer<typeof ManifestSchema>;
|
|
368
|
+
declare const ManifestProblemSchema: z.ZodObject<{
|
|
369
|
+
severity: z.ZodEnum<{
|
|
370
|
+
error: "error";
|
|
371
|
+
warning: "warning";
|
|
372
|
+
}>;
|
|
373
|
+
message: z.ZodString;
|
|
374
|
+
path: z.ZodOptional<z.ZodString>;
|
|
375
|
+
}, z.core.$strip>;
|
|
376
|
+
type ManifestProblem = z.infer<typeof ManifestProblemSchema>;
|
|
377
|
+
declare function readManifest(pkg: Package): Manifest;
|
|
378
|
+
interface BuildManifestOptions {
|
|
379
|
+
documentMediaType?: string;
|
|
380
|
+
version?: string;
|
|
381
|
+
mediaTypeOverrides?: Readonly<Record<string, string>>;
|
|
382
|
+
}
|
|
383
|
+
declare function buildManifest(pkg: Package, options?: BuildManifestOptions): Manifest;
|
|
384
|
+
declare function writeManifest(pkg: Package, manifest: Manifest): void;
|
|
385
|
+
declare function syncManifest(pkg: Package, options?: BuildManifestOptions): void;
|
|
386
|
+
declare function validateManifest(pkg: Package): ManifestProblem[];
|
|
387
|
+
declare function setDocumentMediaType(pkg: Package, mediaType: string, version?: string): void;
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/styles/properties.d.ts
|
|
390
|
+
declare const StylePropertiesSchema: z.ZodObject<{
|
|
391
|
+
bold: z.ZodOptional<z.ZodBoolean>;
|
|
392
|
+
italic: z.ZodOptional<z.ZodBoolean>;
|
|
393
|
+
underline: z.ZodOptional<z.ZodBoolean>;
|
|
394
|
+
strike: z.ZodOptional<z.ZodBoolean>;
|
|
395
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
396
|
+
sizePt: z.ZodOptional<z.ZodNumber>;
|
|
397
|
+
color: z.ZodOptional<z.ZodObject<{
|
|
398
|
+
r: z.ZodNumber;
|
|
399
|
+
g: z.ZodNumber;
|
|
400
|
+
b: z.ZodNumber;
|
|
401
|
+
}, z.core.$strip>>;
|
|
402
|
+
alignment: z.ZodOptional<z.ZodEnum<{
|
|
403
|
+
left: "left";
|
|
404
|
+
center: "center";
|
|
405
|
+
right: "right";
|
|
406
|
+
justify: "justify";
|
|
407
|
+
}>>;
|
|
408
|
+
spacingBeforePt: z.ZodOptional<z.ZodNumber>;
|
|
409
|
+
spacingAfterPt: z.ZodOptional<z.ZodNumber>;
|
|
410
|
+
lineSpacing: z.ZodOptional<z.ZodNumber>;
|
|
411
|
+
indentLeftPt: z.ZodOptional<z.ZodNumber>;
|
|
412
|
+
indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
|
|
413
|
+
}, z.core.$strip>;
|
|
414
|
+
type StyleProperties = z.infer<typeof StylePropertiesSchema>;
|
|
415
|
+
interface ParsedProperties {
|
|
416
|
+
properties: Partial<StyleProperties>;
|
|
417
|
+
hasUnknown: boolean;
|
|
418
|
+
}
|
|
419
|
+
declare function parseLength(value: string): number | undefined;
|
|
420
|
+
declare function formatPt(valuePt: number): string;
|
|
421
|
+
declare function formatPercentageMultiplier(multiplier: number): string;
|
|
422
|
+
declare function parseTextProperties(element: XmlElement): ParsedProperties;
|
|
423
|
+
declare function parseParagraphProperties(element: XmlElement): ParsedProperties;
|
|
424
|
+
declare function parseStyleElementProperties(styleElement: XmlElement): {
|
|
425
|
+
properties: StyleProperties;
|
|
426
|
+
hasUnknown: boolean;
|
|
427
|
+
};
|
|
428
|
+
declare function textPropertiesToAttributes(properties: StyleProperties): Attribute[];
|
|
429
|
+
declare function paragraphPropertiesToAttributes(properties: StyleProperties): Attribute[];
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/styles/serialize.d.ts
|
|
432
|
+
declare function buildStylePropertyElements(properties: StyleProperties): XmlElement[];
|
|
433
|
+
declare function canonicalPropertiesString(properties: StyleProperties): string;
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/styles/registry.d.ts
|
|
436
|
+
declare const STYLE_FAMILIES: readonly ["paragraph", "text", "table", "table-column", "table-row", "table-cell", "graphic"];
|
|
437
|
+
type StyleFamily = (typeof STYLE_FAMILIES)[number];
|
|
438
|
+
interface InternRequest {
|
|
439
|
+
properties: StyleProperties;
|
|
440
|
+
family: StyleFamily;
|
|
441
|
+
parentStyleName?: string;
|
|
442
|
+
}
|
|
443
|
+
interface OtherPartRef {
|
|
444
|
+
pkg: Package;
|
|
445
|
+
partPath: string;
|
|
446
|
+
}
|
|
447
|
+
interface StyleRegistryOptions {
|
|
448
|
+
otherPart?: OtherPartRef;
|
|
449
|
+
additionalReservedNames?: readonly string[];
|
|
450
|
+
}
|
|
451
|
+
declare class StyleRegistry {
|
|
452
|
+
private readonly automaticStyles;
|
|
453
|
+
private readonly prefixes;
|
|
454
|
+
private readonly reservedByFamily;
|
|
455
|
+
private readonly knownStyles;
|
|
456
|
+
private readonly fingerprintToName;
|
|
457
|
+
private readonly nameToFingerprint;
|
|
458
|
+
private readonly familyCounters;
|
|
459
|
+
private constructor();
|
|
460
|
+
static forPart(pkg: Package, partPath: string, options?: StyleRegistryOptions): StyleRegistry;
|
|
461
|
+
fingerprint(request: InternRequest): string;
|
|
462
|
+
intern(request: InternRequest): string;
|
|
463
|
+
private mintName;
|
|
464
|
+
names(): readonly string[];
|
|
465
|
+
gc(referenced: ReadonlySet<string>): number;
|
|
466
|
+
}
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/styles/span.d.ts
|
|
469
|
+
declare function ensureSpan(paragraph: XmlElement, start: number, end: number, styleName: string): XmlElement;
|
|
470
|
+
//#endregion
|
|
471
|
+
export { type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type ImageFormat, type InternRequest, MANIFEST_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, type OdfExtension, type OdfNamespacePrefix, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, base64ToBytes, buildManifest, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, decodePackage, el, encodePackage, encodeXmlText, ensureSpan, formatPercentageMultiplier, formatPt, isXmlNode, mediaTypeForExtension, packageCodec, paragraphPropertiesToAttributes, parseLength, parsePackage, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, readManifest, readMimetype, serializePackage, setDocumentMediaType, sniffImageFormat, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
|
package/dist/index.d.ts
CHANGED
|
@@ -263,6 +263,8 @@ declare function encodePackage(pkg: Package): Uint8Array<ArrayBuffer>;
|
|
|
263
263
|
declare function parsePackage(bytes: Uint8Array<ArrayBuffer>): Package;
|
|
264
264
|
//#endregion
|
|
265
265
|
//#region src/package-io/write.d.ts
|
|
266
|
+
declare const MIMETYPE_PART = "mimetype";
|
|
267
|
+
declare const MANIFEST_PART = "META-INF/manifest.xml";
|
|
266
268
|
declare function serializePackage(pkg: Package): Uint8Array<ArrayBuffer>;
|
|
267
269
|
//#endregion
|
|
268
270
|
//#region src/xml/parse.d.ts
|
|
@@ -283,4 +285,187 @@ declare function zipPackage(entries: readonly (readonly [string, ZipEntry])[]):
|
|
|
283
285
|
declare function bytesToBase64(bytes: Uint8Array<ArrayBuffer>): string;
|
|
284
286
|
declare function base64ToBytes(b64: string): Uint8Array<ArrayBuffer>;
|
|
285
287
|
//#endregion
|
|
286
|
-
|
|
288
|
+
//#region src/ns.d.ts
|
|
289
|
+
declare const ODF_NAMESPACES: Readonly<{
|
|
290
|
+
office: "urn:oasis:names:tc:opendocument:xmlns:office:1.0";
|
|
291
|
+
style: "urn:oasis:names:tc:opendocument:xmlns:style:1.0";
|
|
292
|
+
text: "urn:oasis:names:tc:opendocument:xmlns:text:1.0";
|
|
293
|
+
table: "urn:oasis:names:tc:opendocument:xmlns:table:1.0";
|
|
294
|
+
draw: "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0";
|
|
295
|
+
fo: "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0";
|
|
296
|
+
svg: "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0";
|
|
297
|
+
xlink: "http://www.w3.org/1999/xlink";
|
|
298
|
+
dc: "http://purl.org/dc/elements/1.1/";
|
|
299
|
+
meta: "urn:oasis:names:tc:opendocument:xmlns:meta:1.0";
|
|
300
|
+
number: "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0";
|
|
301
|
+
chart: "urn:oasis:names:tc:opendocument:xmlns:chart:1.0";
|
|
302
|
+
dr3d: "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0";
|
|
303
|
+
math: "http://www.w3.org/1998/Math/MathML";
|
|
304
|
+
form: "urn:oasis:names:tc:opendocument:xmlns:form:1.0";
|
|
305
|
+
script: "urn:oasis:names:tc:opendocument:xmlns:script:1.0";
|
|
306
|
+
config: "urn:oasis:names:tc:opendocument:xmlns:config:1.0";
|
|
307
|
+
presentation: "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0";
|
|
308
|
+
smil: "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0";
|
|
309
|
+
anim: "urn:oasis:names:tc:opendocument:xmlns:animation:1.0";
|
|
310
|
+
xforms: "http://www.w3.org/2002/xforms";
|
|
311
|
+
xsd: "http://www.w3.org/2001/XMLSchema";
|
|
312
|
+
xsi: "http://www.w3.org/2001/XMLSchema-instance";
|
|
313
|
+
manifest: "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
|
|
314
|
+
}>;
|
|
315
|
+
type OdfNamespacePrefix = keyof typeof ODF_NAMESPACES;
|
|
316
|
+
declare function xmlnsAttributes(prefixes: readonly OdfNamespacePrefix[]): Record<string, string>;
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/media-type.d.ts
|
|
319
|
+
declare const ODF_MEDIA_TYPES: Readonly<{
|
|
320
|
+
odt: "application/vnd.oasis.opendocument.text";
|
|
321
|
+
ott: "application/vnd.oasis.opendocument.text-template";
|
|
322
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet";
|
|
323
|
+
ots: "application/vnd.oasis.opendocument.spreadsheet-template";
|
|
324
|
+
odp: "application/vnd.oasis.opendocument.presentation";
|
|
325
|
+
otp: "application/vnd.oasis.opendocument.presentation-template";
|
|
326
|
+
odg: "application/vnd.oasis.opendocument.graphics";
|
|
327
|
+
otg: "application/vnd.oasis.opendocument.graphics-template";
|
|
328
|
+
odf: "application/vnd.oasis.opendocument.formula";
|
|
329
|
+
otf: "application/vnd.oasis.opendocument.formula-template";
|
|
330
|
+
odm: "application/vnd.oasis.opendocument.text-master";
|
|
331
|
+
otm: "application/vnd.oasis.opendocument.text-master-template";
|
|
332
|
+
odb: "application/vnd.oasis.opendocument.base";
|
|
333
|
+
}>;
|
|
334
|
+
type OdfExtension = keyof typeof ODF_MEDIA_TYPES;
|
|
335
|
+
declare function mediaTypeForExtension(extension: string): string | undefined;
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/image/sniff.d.ts
|
|
338
|
+
type ImageFormat = 'png' | 'jpeg';
|
|
339
|
+
declare function sniffImageFormat(bytes: Uint8Array<ArrayBuffer>): ImageFormat | undefined;
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/mimetype.d.ts
|
|
342
|
+
declare function readMimetype(pkg: Package): string | undefined;
|
|
343
|
+
declare function writeMimetype(pkg: Package, mediaType: string): void;
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/xml/fragment.d.ts
|
|
346
|
+
declare function el(tag: string, attrs?: Record<string, string>, children?: XmlNode[]): XmlElement;
|
|
347
|
+
declare function txt(value: string): XmlText;
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/xml/entities.d.ts
|
|
350
|
+
declare function encodeXmlText(value: string): string;
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/manifest.d.ts
|
|
353
|
+
declare const ManifestEntrySchema: z.ZodObject<{
|
|
354
|
+
fullPath: z.ZodString;
|
|
355
|
+
mediaType: z.ZodString;
|
|
356
|
+
version: z.ZodOptional<z.ZodString>;
|
|
357
|
+
}, z.core.$strip>;
|
|
358
|
+
type ManifestEntry = z.infer<typeof ManifestEntrySchema>;
|
|
359
|
+
declare const ManifestSchema: z.ZodObject<{
|
|
360
|
+
version: z.ZodString;
|
|
361
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
362
|
+
fullPath: z.ZodString;
|
|
363
|
+
mediaType: z.ZodString;
|
|
364
|
+
version: z.ZodOptional<z.ZodString>;
|
|
365
|
+
}, z.core.$strip>>;
|
|
366
|
+
}, z.core.$strip>;
|
|
367
|
+
type Manifest = z.infer<typeof ManifestSchema>;
|
|
368
|
+
declare const ManifestProblemSchema: z.ZodObject<{
|
|
369
|
+
severity: z.ZodEnum<{
|
|
370
|
+
error: "error";
|
|
371
|
+
warning: "warning";
|
|
372
|
+
}>;
|
|
373
|
+
message: z.ZodString;
|
|
374
|
+
path: z.ZodOptional<z.ZodString>;
|
|
375
|
+
}, z.core.$strip>;
|
|
376
|
+
type ManifestProblem = z.infer<typeof ManifestProblemSchema>;
|
|
377
|
+
declare function readManifest(pkg: Package): Manifest;
|
|
378
|
+
interface BuildManifestOptions {
|
|
379
|
+
documentMediaType?: string;
|
|
380
|
+
version?: string;
|
|
381
|
+
mediaTypeOverrides?: Readonly<Record<string, string>>;
|
|
382
|
+
}
|
|
383
|
+
declare function buildManifest(pkg: Package, options?: BuildManifestOptions): Manifest;
|
|
384
|
+
declare function writeManifest(pkg: Package, manifest: Manifest): void;
|
|
385
|
+
declare function syncManifest(pkg: Package, options?: BuildManifestOptions): void;
|
|
386
|
+
declare function validateManifest(pkg: Package): ManifestProblem[];
|
|
387
|
+
declare function setDocumentMediaType(pkg: Package, mediaType: string, version?: string): void;
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/styles/properties.d.ts
|
|
390
|
+
declare const StylePropertiesSchema: z.ZodObject<{
|
|
391
|
+
bold: z.ZodOptional<z.ZodBoolean>;
|
|
392
|
+
italic: z.ZodOptional<z.ZodBoolean>;
|
|
393
|
+
underline: z.ZodOptional<z.ZodBoolean>;
|
|
394
|
+
strike: z.ZodOptional<z.ZodBoolean>;
|
|
395
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
396
|
+
sizePt: z.ZodOptional<z.ZodNumber>;
|
|
397
|
+
color: z.ZodOptional<z.ZodObject<{
|
|
398
|
+
r: z.ZodNumber;
|
|
399
|
+
g: z.ZodNumber;
|
|
400
|
+
b: z.ZodNumber;
|
|
401
|
+
}, z.core.$strip>>;
|
|
402
|
+
alignment: z.ZodOptional<z.ZodEnum<{
|
|
403
|
+
left: "left";
|
|
404
|
+
center: "center";
|
|
405
|
+
right: "right";
|
|
406
|
+
justify: "justify";
|
|
407
|
+
}>>;
|
|
408
|
+
spacingBeforePt: z.ZodOptional<z.ZodNumber>;
|
|
409
|
+
spacingAfterPt: z.ZodOptional<z.ZodNumber>;
|
|
410
|
+
lineSpacing: z.ZodOptional<z.ZodNumber>;
|
|
411
|
+
indentLeftPt: z.ZodOptional<z.ZodNumber>;
|
|
412
|
+
indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
|
|
413
|
+
}, z.core.$strip>;
|
|
414
|
+
type StyleProperties = z.infer<typeof StylePropertiesSchema>;
|
|
415
|
+
interface ParsedProperties {
|
|
416
|
+
properties: Partial<StyleProperties>;
|
|
417
|
+
hasUnknown: boolean;
|
|
418
|
+
}
|
|
419
|
+
declare function parseLength(value: string): number | undefined;
|
|
420
|
+
declare function formatPt(valuePt: number): string;
|
|
421
|
+
declare function formatPercentageMultiplier(multiplier: number): string;
|
|
422
|
+
declare function parseTextProperties(element: XmlElement): ParsedProperties;
|
|
423
|
+
declare function parseParagraphProperties(element: XmlElement): ParsedProperties;
|
|
424
|
+
declare function parseStyleElementProperties(styleElement: XmlElement): {
|
|
425
|
+
properties: StyleProperties;
|
|
426
|
+
hasUnknown: boolean;
|
|
427
|
+
};
|
|
428
|
+
declare function textPropertiesToAttributes(properties: StyleProperties): Attribute[];
|
|
429
|
+
declare function paragraphPropertiesToAttributes(properties: StyleProperties): Attribute[];
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/styles/serialize.d.ts
|
|
432
|
+
declare function buildStylePropertyElements(properties: StyleProperties): XmlElement[];
|
|
433
|
+
declare function canonicalPropertiesString(properties: StyleProperties): string;
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/styles/registry.d.ts
|
|
436
|
+
declare const STYLE_FAMILIES: readonly ["paragraph", "text", "table", "table-column", "table-row", "table-cell", "graphic"];
|
|
437
|
+
type StyleFamily = (typeof STYLE_FAMILIES)[number];
|
|
438
|
+
interface InternRequest {
|
|
439
|
+
properties: StyleProperties;
|
|
440
|
+
family: StyleFamily;
|
|
441
|
+
parentStyleName?: string;
|
|
442
|
+
}
|
|
443
|
+
interface OtherPartRef {
|
|
444
|
+
pkg: Package;
|
|
445
|
+
partPath: string;
|
|
446
|
+
}
|
|
447
|
+
interface StyleRegistryOptions {
|
|
448
|
+
otherPart?: OtherPartRef;
|
|
449
|
+
additionalReservedNames?: readonly string[];
|
|
450
|
+
}
|
|
451
|
+
declare class StyleRegistry {
|
|
452
|
+
private readonly automaticStyles;
|
|
453
|
+
private readonly prefixes;
|
|
454
|
+
private readonly reservedByFamily;
|
|
455
|
+
private readonly knownStyles;
|
|
456
|
+
private readonly fingerprintToName;
|
|
457
|
+
private readonly nameToFingerprint;
|
|
458
|
+
private readonly familyCounters;
|
|
459
|
+
private constructor();
|
|
460
|
+
static forPart(pkg: Package, partPath: string, options?: StyleRegistryOptions): StyleRegistry;
|
|
461
|
+
fingerprint(request: InternRequest): string;
|
|
462
|
+
intern(request: InternRequest): string;
|
|
463
|
+
private mintName;
|
|
464
|
+
names(): readonly string[];
|
|
465
|
+
gc(referenced: ReadonlySet<string>): number;
|
|
466
|
+
}
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/styles/span.d.ts
|
|
469
|
+
declare function ensureSpan(paragraph: XmlElement, start: number, end: number, styleName: string): XmlElement;
|
|
470
|
+
//#endregion
|
|
471
|
+
export { type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type ImageFormat, type InternRequest, MANIFEST_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, type OdfExtension, type OdfNamespacePrefix, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, base64ToBytes, buildManifest, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, decodePackage, el, encodePackage, encodeXmlText, ensureSpan, formatPercentageMultiplier, formatPt, isXmlNode, mediaTypeForExtension, packageCodec, paragraphPropertiesToAttributes, parseLength, parsePackage, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, readManifest, readMimetype, serializePackage, setDocumentMediaType, sniffImageFormat, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
|