odf.js 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { Alignment, AlignmentSchema, Box, Color, LayoutMetadata, Margins, PageSize } from "document-content-model";
2
3
  //#region src/model/node.d.ts
3
4
  declare const AttributeSchema: z.ZodObject<{
4
5
  name: z.ZodString;
@@ -348,6 +349,7 @@ declare function txt(value: string): XmlText;
348
349
  //#endregion
349
350
  //#region src/xml/entities.d.ts
350
351
  declare function encodeXmlText(value: string): string;
352
+ declare function decodeXmlText(value: string): string;
351
353
  //#endregion
352
354
  //#region src/manifest.d.ts
353
355
  declare const ManifestEntrySchema: z.ZodObject<{
@@ -386,6 +388,11 @@ declare function syncManifest(pkg: Package, options?: BuildManifestOptions): voi
386
388
  declare function validateManifest(pkg: Package): ManifestProblem[];
387
389
  declare function setDocumentMediaType(pkg: Package, mediaType: string, version?: string): void;
388
390
  //#endregion
391
+ //#region src/typed/shared/units.d.ts
392
+ type LengthUnit = 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'px';
393
+ declare function parseOdfLength(value: string): number | undefined;
394
+ declare function formatOdfLength(pt: number, unit?: LengthUnit): string;
395
+ //#endregion
389
396
  //#region src/styles/properties.d.ts
390
397
  declare const StylePropertiesSchema: z.ZodObject<{
391
398
  bold: z.ZodOptional<z.ZodBoolean>;
@@ -416,7 +423,7 @@ interface ParsedProperties {
416
423
  properties: Partial<StyleProperties>;
417
424
  hasUnknown: boolean;
418
425
  }
419
- declare function parseLength(value: string): number | undefined;
426
+ declare const parseLength: typeof parseOdfLength;
420
427
  declare function formatPt(valuePt: number): string;
421
428
  declare function formatPercentageMultiplier(multiplier: number): string;
422
429
  declare function parseTextProperties(element: XmlElement): ParsedProperties;
@@ -435,6 +442,7 @@ declare function canonicalPropertiesString(properties: StyleProperties): string;
435
442
  //#region src/styles/registry.d.ts
436
443
  declare const STYLE_FAMILIES: readonly ["paragraph", "text", "table", "table-column", "table-row", "table-cell", "graphic"];
437
444
  type StyleFamily = (typeof STYLE_FAMILIES)[number];
445
+ declare function isStyleFamily(value: string): value is StyleFamily;
438
446
  interface InternRequest {
439
447
  properties: StyleProperties;
440
448
  family: StyleFamily;
@@ -468,4 +476,52 @@ declare class StyleRegistry {
468
476
  //#region src/styles/span.d.ts
469
477
  declare function ensureSpan(paragraph: XmlElement, start: number, end: number, styleName: string): XmlElement;
470
478
  //#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 };
479
+ //#region src/xml/query.d.ts
480
+ declare function rootElement(nodes: readonly XmlNode[]): XmlElement | undefined;
481
+ declare function findChildElement(nodes: readonly XmlNode[], tag: string): XmlElement | undefined;
482
+ declare function childrenWithTag(element: XmlElement, tag: string): XmlElement[];
483
+ declare function attrValue(element: XmlElement, name: string): string | undefined;
484
+ //#endregion
485
+ //#region src/typed/shared/a1.d.ts
486
+ declare function columnIndexToLetters(index: number): string;
487
+ declare function cellReference(columnIndex: number, rowIndex: number): string;
488
+ declare class TableCursor {
489
+ private columnCursor;
490
+ private rowCursor;
491
+ get columnIndex(): number;
492
+ get rowIndex(): number;
493
+ nextCell(repeatCount?: number): string;
494
+ nextRow(repeatCount?: number): void;
495
+ }
496
+ //#endregion
497
+ //#region src/typed/shared/color.d.ts
498
+ declare function parseOdfColor(value: string): Color | undefined;
499
+ declare function formatOdfColor(color: Color): string;
500
+ //#endregion
501
+ //#region src/typed/shared/geometry.d.ts
502
+ declare function parsePageSize(pageLayoutProperties: XmlElement): PageSize | undefined;
503
+ declare function parseMargins(pageLayoutProperties: XmlElement): Margins | undefined;
504
+ declare function parseBox(element: XmlElement): Box | undefined;
505
+ //#endregion
506
+ //#region src/typed/shared/text.d.ts
507
+ declare function getOdfSpaceCount(element: XmlElement): number;
508
+ declare function measureOdfNodeLength(node: XmlNode): number;
509
+ declare function sumOdfNodeLength(nodes: readonly XmlNode[]): number;
510
+ declare function decodeOdfText(container: XmlElement): string;
511
+ //#endregion
512
+ //#region src/typed/shared/cascade.d.ts
513
+ interface CascadeDiagnostic {
514
+ severity: 'warning';
515
+ message: string;
516
+ }
517
+ interface StyleCascadeResult {
518
+ properties: StyleProperties;
519
+ diagnostics: CascadeDiagnostic[];
520
+ }
521
+ declare function resolveStyle(styleName: string | undefined, family: StyleFamily, pkg: Package): StyleCascadeResult;
522
+ //#endregion
523
+ //#region src/typed/shared/metadata.d.ts
524
+ declare const META_PART = "meta.xml";
525
+ declare function readOdfMetadata(pkg: Package): LayoutMetadata;
526
+ //#endregion
527
+ export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_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 StyleCascadeResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, TableCursor, 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, attrValue, base64ToBytes, buildManifest, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, decodeOdfText, decodePackage, decodeXmlText, el, encodePackage, encodeXmlText, ensureSpan, findChildElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, packageCodec, paragraphPropertiesToAttributes, parseBox, parseLength, parseMargins, parseOdfColor, parseOdfLength, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, readManifest, readMimetype, readOdfMetadata, resolveStyle, rootElement, serializePackage, setDocumentMediaType, sniffImageFormat, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { Alignment, AlignmentSchema, Box, Color, LayoutMetadata, Margins, PageSize } from "document-content-model";
2
3
  //#region src/model/node.d.ts
3
4
  declare const AttributeSchema: z.ZodObject<{
4
5
  name: z.ZodString;
@@ -348,6 +349,7 @@ declare function txt(value: string): XmlText;
348
349
  //#endregion
349
350
  //#region src/xml/entities.d.ts
350
351
  declare function encodeXmlText(value: string): string;
352
+ declare function decodeXmlText(value: string): string;
351
353
  //#endregion
352
354
  //#region src/manifest.d.ts
353
355
  declare const ManifestEntrySchema: z.ZodObject<{
@@ -386,6 +388,11 @@ declare function syncManifest(pkg: Package, options?: BuildManifestOptions): voi
386
388
  declare function validateManifest(pkg: Package): ManifestProblem[];
387
389
  declare function setDocumentMediaType(pkg: Package, mediaType: string, version?: string): void;
388
390
  //#endregion
391
+ //#region src/typed/shared/units.d.ts
392
+ type LengthUnit = 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'px';
393
+ declare function parseOdfLength(value: string): number | undefined;
394
+ declare function formatOdfLength(pt: number, unit?: LengthUnit): string;
395
+ //#endregion
389
396
  //#region src/styles/properties.d.ts
390
397
  declare const StylePropertiesSchema: z.ZodObject<{
391
398
  bold: z.ZodOptional<z.ZodBoolean>;
@@ -416,7 +423,7 @@ interface ParsedProperties {
416
423
  properties: Partial<StyleProperties>;
417
424
  hasUnknown: boolean;
418
425
  }
419
- declare function parseLength(value: string): number | undefined;
426
+ declare const parseLength: typeof parseOdfLength;
420
427
  declare function formatPt(valuePt: number): string;
421
428
  declare function formatPercentageMultiplier(multiplier: number): string;
422
429
  declare function parseTextProperties(element: XmlElement): ParsedProperties;
@@ -435,6 +442,7 @@ declare function canonicalPropertiesString(properties: StyleProperties): string;
435
442
  //#region src/styles/registry.d.ts
436
443
  declare const STYLE_FAMILIES: readonly ["paragraph", "text", "table", "table-column", "table-row", "table-cell", "graphic"];
437
444
  type StyleFamily = (typeof STYLE_FAMILIES)[number];
445
+ declare function isStyleFamily(value: string): value is StyleFamily;
438
446
  interface InternRequest {
439
447
  properties: StyleProperties;
440
448
  family: StyleFamily;
@@ -468,4 +476,52 @@ declare class StyleRegistry {
468
476
  //#region src/styles/span.d.ts
469
477
  declare function ensureSpan(paragraph: XmlElement, start: number, end: number, styleName: string): XmlElement;
470
478
  //#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 };
479
+ //#region src/xml/query.d.ts
480
+ declare function rootElement(nodes: readonly XmlNode[]): XmlElement | undefined;
481
+ declare function findChildElement(nodes: readonly XmlNode[], tag: string): XmlElement | undefined;
482
+ declare function childrenWithTag(element: XmlElement, tag: string): XmlElement[];
483
+ declare function attrValue(element: XmlElement, name: string): string | undefined;
484
+ //#endregion
485
+ //#region src/typed/shared/a1.d.ts
486
+ declare function columnIndexToLetters(index: number): string;
487
+ declare function cellReference(columnIndex: number, rowIndex: number): string;
488
+ declare class TableCursor {
489
+ private columnCursor;
490
+ private rowCursor;
491
+ get columnIndex(): number;
492
+ get rowIndex(): number;
493
+ nextCell(repeatCount?: number): string;
494
+ nextRow(repeatCount?: number): void;
495
+ }
496
+ //#endregion
497
+ //#region src/typed/shared/color.d.ts
498
+ declare function parseOdfColor(value: string): Color | undefined;
499
+ declare function formatOdfColor(color: Color): string;
500
+ //#endregion
501
+ //#region src/typed/shared/geometry.d.ts
502
+ declare function parsePageSize(pageLayoutProperties: XmlElement): PageSize | undefined;
503
+ declare function parseMargins(pageLayoutProperties: XmlElement): Margins | undefined;
504
+ declare function parseBox(element: XmlElement): Box | undefined;
505
+ //#endregion
506
+ //#region src/typed/shared/text.d.ts
507
+ declare function getOdfSpaceCount(element: XmlElement): number;
508
+ declare function measureOdfNodeLength(node: XmlNode): number;
509
+ declare function sumOdfNodeLength(nodes: readonly XmlNode[]): number;
510
+ declare function decodeOdfText(container: XmlElement): string;
511
+ //#endregion
512
+ //#region src/typed/shared/cascade.d.ts
513
+ interface CascadeDiagnostic {
514
+ severity: 'warning';
515
+ message: string;
516
+ }
517
+ interface StyleCascadeResult {
518
+ properties: StyleProperties;
519
+ diagnostics: CascadeDiagnostic[];
520
+ }
521
+ declare function resolveStyle(styleName: string | undefined, family: StyleFamily, pkg: Package): StyleCascadeResult;
522
+ //#endregion
523
+ //#region src/typed/shared/metadata.d.ts
524
+ declare const META_PART = "meta.xml";
525
+ declare function readOdfMetadata(pkg: Package): LayoutMetadata;
526
+ //#endregion
527
+ export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_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 StyleCascadeResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, TableCursor, 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, attrValue, base64ToBytes, buildManifest, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, decodeOdfText, decodePackage, decodeXmlText, el, encodePackage, encodeXmlText, ensureSpan, findChildElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, packageCodec, paragraphPropertiesToAttributes, parseBox, parseLength, parseMargins, parseOdfColor, parseOdfLength, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, readManifest, readMimetype, readOdfMetadata, resolveStyle, rootElement, serializePackage, setDocumentMediaType, sniffImageFormat, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };