Initial commit
This commit is contained in:
commit
e49726988c
5445 files changed
+1089914
No files matched your search
+4902
File diff suppressed because it is too large.
Load diff
+4834
File diff suppressed because it is too large.
Load diff
+8
@@ -0,0 +1,8 @@
|
||||
import { OpenXmlPart } from "src/office";
|
||||
import { XmlTextNode } from "src/xml";
|
||||
export interface DelimiterMark {
|
||||
xmlTextNode: XmlTextNode;
|
||||
openXmlPart?: OpenXmlPart;
|
||||
index: number;
|
||||
isOpen: boolean;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { XmlNode } from "src/xml";
|
||||
import { DelimiterMark } from "./delimiterMark";
|
||||
export declare class DelimiterSearcher {
|
||||
maxXmlDepth: number;
|
||||
startDelimiter: string;
|
||||
endDelimiter: string;
|
||||
findDelimiters(node: XmlNode): DelimiterMark[];
|
||||
private noMatch;
|
||||
private fullMatch;
|
||||
private shouldSearchNode;
|
||||
private createDelimiterMark;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export * from './delimiterMark';
|
||||
export * from './delimiterSearcher';
|
||||
export * from './scopeData';
|
||||
export * from './tag';
|
||||
export * from './tagParser';
|
||||
export * from './templateCompiler';
|
||||
export * from './templateContext';
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { TemplateContent, TemplateData } from '../templateData';
|
||||
import { Tag } from './tag';
|
||||
export type PathPart = Tag | number;
|
||||
export interface ScopeDataArgs {
|
||||
path: PathPart[];
|
||||
strPath: string[];
|
||||
data: TemplateData;
|
||||
}
|
||||
export type ScopeDataResolver = (args: ScopeDataArgs) => TemplateContent | TemplateData[];
|
||||
export declare class ScopeData {
|
||||
static defaultResolver(args: ScopeDataArgs): TemplateContent | TemplateData[];
|
||||
scopeDataResolver: ScopeDataResolver;
|
||||
allData: TemplateData;
|
||||
private readonly path;
|
||||
private readonly strPath;
|
||||
constructor(data: TemplateData);
|
||||
pathPush(pathPart: PathPart): void;
|
||||
pathPop(): Tag | number;
|
||||
pathString(): string;
|
||||
getScopeData<T extends TemplateContent | TemplateData[]>(): T;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { IMap } from "src/types";
|
||||
import { XmlTextNode } from "src/xml";
|
||||
export declare const TagDisposition: Readonly<{
|
||||
readonly Open: "Open";
|
||||
readonly Close: "Close";
|
||||
readonly SelfClosed: "SelfClosed";
|
||||
}>;
|
||||
export type TagDisposition = typeof TagDisposition[keyof typeof TagDisposition];
|
||||
export interface Tag {
|
||||
name: string;
|
||||
options?: IMap<any>;
|
||||
rawText: string;
|
||||
disposition: TagDisposition;
|
||||
xmlTextNode: XmlTextNode;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { Delimiters } from "src/delimiters";
|
||||
import { DelimiterMark } from "./delimiterMark";
|
||||
import { Tag } from "./tag";
|
||||
export declare class TagParser {
|
||||
private readonly tagRegex;
|
||||
private readonly delimiters;
|
||||
constructor(delimiters: Delimiters);
|
||||
parse(delimiters: DelimiterMark[]): Tag[];
|
||||
private normalizeTagNodes;
|
||||
private processTag;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { TemplatePlugin } from '../plugins';
|
||||
import { XmlNode } from '../xml';
|
||||
import { DelimiterSearcher } from './delimiterSearcher';
|
||||
import { ScopeData } from './scopeData';
|
||||
import { Tag } from './tag';
|
||||
import { TagParser } from './tagParser';
|
||||
import { TemplateContext } from './templateContext';
|
||||
export interface TemplateCompilerOptions {
|
||||
defaultContentType: string;
|
||||
containerContentType: string;
|
||||
skipEmptyTags?: boolean;
|
||||
}
|
||||
export declare class TemplateCompiler {
|
||||
private readonly pluginsLookup;
|
||||
private readonly delimiterSearcher;
|
||||
private readonly tagParser;
|
||||
private readonly options;
|
||||
constructor(delimiterSearcher: DelimiterSearcher, tagParser: TagParser, plugins: TemplatePlugin[], options: TemplateCompilerOptions);
|
||||
compile(node: XmlNode, data: ScopeData, context: TemplateContext): Promise<void>;
|
||||
parseTags(node: XmlNode): Tag[];
|
||||
private doTagReplacements;
|
||||
private detectContentType;
|
||||
private simpleTagReplacements;
|
||||
private findCloseTagIndex;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { Docx, OpenXmlPart } from '../office';
|
||||
export interface TemplateContext {
|
||||
docx: Docx;
|
||||
currentPart: OpenXmlPart;
|
||||
pluginContext: Record<string, any>;
|
||||
options: TemplateOptions;
|
||||
}
|
||||
export interface TemplateOptions {
|
||||
maxXmlDepth: number;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
export declare class Delimiters {
|
||||
tagStart: string;
|
||||
tagEnd: string;
|
||||
containerTagOpen: string;
|
||||
containerTagClose: string;
|
||||
tagOptionsStart: string;
|
||||
tagOptionsEnd: string;
|
||||
constructor(initial?: Partial<Delimiters>);
|
||||
private encodeAndValidate;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
export * from './internalArgumentMissingError';
|
||||
export * from './internalError';
|
||||
export * from './malformedFileError';
|
||||
export * from './maxXmlDepthError';
|
||||
export * from './missingCloseDelimiterError';
|
||||
export * from './missingStartDelimiterError';
|
||||
export * from './tagOptionsParseError';
|
||||
export * from './templateDataError';
|
||||
export * from './templateSyntaxError';
|
||||
export * from './unclosedTagError';
|
||||
export * from './unidentifiedFileTypeError';
|
||||
export * from './unknownContentTypeError';
|
||||
export * from './unopenedTagError';
|
||||
export * from './unsupportedFileTypeError';
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { InternalError } from "./internalError";
|
||||
export declare class InternalArgumentMissingError extends InternalError {
|
||||
readonly argName: string;
|
||||
constructor(argName: string);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export declare class InternalError extends Error {
|
||||
constructor(message: string);
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export declare class MalformedFileError extends Error {
|
||||
readonly expectedFileType: string;
|
||||
constructor(expectedFileType: string);
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export declare class MaxXmlDepthError extends Error {
|
||||
readonly maxDepth: number;
|
||||
constructor(maxDepth: number);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TemplateSyntaxError } from "./templateSyntaxError";
|
||||
export declare class MissingCloseDelimiterError extends TemplateSyntaxError {
|
||||
readonly openDelimiterText: string;
|
||||
constructor(openDelimiterText: string);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TemplateSyntaxError } from "./templateSyntaxError";
|
||||
export declare class MissingStartDelimiterError extends TemplateSyntaxError {
|
||||
readonly closeDelimiterText: string;
|
||||
constructor(closeDelimiterText: string);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { TemplateSyntaxError } from "./templateSyntaxError";
|
||||
export declare class TagOptionsParseError extends TemplateSyntaxError {
|
||||
readonly tagRawText: string;
|
||||
readonly parseError: Error;
|
||||
constructor(tagRawText: string, parseError: Error);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export declare class TemplateDataError extends Error {
|
||||
constructor(message: string);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export declare class TemplateSyntaxError extends Error {
|
||||
constructor(message: string);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TemplateSyntaxError } from "./templateSyntaxError";
|
||||
export declare class UnclosedTagError extends TemplateSyntaxError {
|
||||
readonly tagName: string;
|
||||
constructor(tagName: string);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export declare class UnidentifiedFileTypeError extends Error {
|
||||
constructor();
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { TemplateDataError } from "./templateDataError";
|
||||
export declare class UnknownContentTypeError extends TemplateDataError {
|
||||
readonly tagRawText: string;
|
||||
readonly contentType: string;
|
||||
readonly path: string;
|
||||
constructor(contentType: string, tagRawText: string, path: string);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TemplateSyntaxError } from "./templateSyntaxError";
|
||||
export declare class UnopenedTagError extends TemplateSyntaxError {
|
||||
readonly tagName: string;
|
||||
constructor(tagName: string);
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export declare class UnsupportedFileTypeError extends Error {
|
||||
readonly fileType: string;
|
||||
constructor(fileType: string);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TemplateExtension } from "./templateExtension";
|
||||
export interface ExtensionOptions {
|
||||
beforeCompilation?: TemplateExtension[];
|
||||
afterCompilation?: TemplateExtension[];
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './extensionOptions';
|
||||
export * from './templateExtension';
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { ScopeData, TagParser, TemplateCompiler, TemplateContext } from 'src/compilation';
|
||||
export interface ExtensionUtilities {
|
||||
compiler: TemplateCompiler;
|
||||
tagParser: TagParser;
|
||||
}
|
||||
export declare abstract class TemplateExtension {
|
||||
protected utilities: ExtensionUtilities;
|
||||
setUtilities(utilities: ExtensionUtilities): void;
|
||||
abstract execute(data: ScopeData, context: TemplateContext): void | Promise<void>;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
export * from './compilation';
|
||||
export * from './extensions';
|
||||
export * from './errors';
|
||||
export * from './office';
|
||||
export * from './plugins';
|
||||
export * from './utils';
|
||||
export * from './xml';
|
||||
export * from './zip';
|
||||
export * from './delimiters';
|
||||
export * from './mimeType';
|
||||
export * from './templateData';
|
||||
export * from './templateHandler';
|
||||
export * from './templateHandlerOptions';
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
export declare const MimeType: Readonly<{
|
||||
readonly Png: "image/png";
|
||||
readonly Jpeg: "image/jpeg";
|
||||
readonly Gif: "image/gif";
|
||||
readonly Bmp: "image/bmp";
|
||||
readonly Svg: "image/svg+xml";
|
||||
}>;
|
||||
export type MimeType = typeof MimeType[keyof typeof MimeType];
|
||||
export declare class MimeTypeHelper {
|
||||
static getDefaultExtension(mime: MimeType): string;
|
||||
static getOfficeRelType(mime: MimeType): string;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { MimeType } from "src/mimeType";
|
||||
import { Zip } from "src/zip";
|
||||
export declare class ContentTypesFile {
|
||||
private static readonly contentTypesFilePath;
|
||||
private addedNew;
|
||||
private root;
|
||||
private contentTypes;
|
||||
private readonly zip;
|
||||
constructor(zip: Zip);
|
||||
ensureContentType(mime: MimeType): Promise<void>;
|
||||
count(): Promise<number>;
|
||||
save(): Promise<void>;
|
||||
private parseContentTypesFile;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { Constructor } from "src/types";
|
||||
import { Binary } from "src/utils";
|
||||
import { Zip } from "src/zip";
|
||||
import { ContentTypesFile } from "./contentTypesFile";
|
||||
import { MediaFiles } from "./mediaFiles";
|
||||
import { OpenXmlPart } from "./openXmlPart";
|
||||
export declare class Docx {
|
||||
static load(file: Binary): Promise<Docx>;
|
||||
static open(zip: Zip): Promise<Docx>;
|
||||
private static getMainDocumentPath;
|
||||
readonly mainDocument: OpenXmlPart;
|
||||
readonly mediaFiles: MediaFiles;
|
||||
readonly contentTypes: ContentTypesFile;
|
||||
private readonly zip;
|
||||
get rawZipFile(): Zip;
|
||||
private constructor();
|
||||
getContentParts(): Promise<OpenXmlPart[]>;
|
||||
export<T extends Binary>(outputType?: Constructor<T>): Promise<T>;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export * from './docx';
|
||||
export * from './omlNode';
|
||||
export * from './officeMarkup';
|
||||
export * from './openXmlPart';
|
||||
export * from './relationship';
|
||||
export * from './xlsx';
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { MimeType } from '../mimeType';
|
||||
import { Binary } from '../utils';
|
||||
import { Zip } from '../zip';
|
||||
export declare class MediaFiles {
|
||||
private static readonly mediaDir;
|
||||
private hashes;
|
||||
private readonly files;
|
||||
private nextFileId;
|
||||
private readonly zip;
|
||||
constructor(zip: Zip);
|
||||
add(mediaFile: Binary, mime: MimeType): Promise<string>;
|
||||
count(): Promise<number>;
|
||||
private hashMediaFiles;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import { XmlGeneralNode, XmlNode, XmlTextNode } from "src/xml";
|
||||
export declare class OfficeMarkup {
|
||||
readonly query: Query;
|
||||
readonly modify: Modify;
|
||||
}
|
||||
declare class Query {
|
||||
isTextNode(node: XmlNode): boolean;
|
||||
isRunNode(node: XmlNode): boolean;
|
||||
isRunPropertiesNode(node: XmlNode): boolean;
|
||||
isTableCellNode(node: XmlNode): boolean;
|
||||
isParagraphNode(node: XmlNode): boolean;
|
||||
isParagraphPropertiesNode(node: XmlNode): boolean;
|
||||
isListParagraph(paragraphNode: XmlNode): boolean;
|
||||
findParagraphPropertiesNode(paragraphNode: XmlNode): XmlNode;
|
||||
firstTextNodeChild(node: XmlNode): XmlNode;
|
||||
containingTextNode(node: XmlTextNode): XmlGeneralNode;
|
||||
containingRunNode(node: XmlNode): XmlNode;
|
||||
containingParagraphNode(node: XmlNode): XmlNode;
|
||||
containingTableRowNode(node: XmlNode): XmlNode;
|
||||
containingTableCellNode(node: XmlNode): XmlNode;
|
||||
containingTableNode(node: XmlNode): XmlNode;
|
||||
isEmptyTextNode(node: XmlNode): boolean;
|
||||
isEmptyRun(node: XmlNode): boolean;
|
||||
}
|
||||
declare class Modify {
|
||||
splitTextNode(textNode: XmlTextNode, splitIndex: number, addBefore: boolean): XmlTextNode;
|
||||
splitParagraphByTextNode(paragraph: XmlNode, textNode: XmlTextNode, removeTextNode: boolean): [XmlNode, XmlNode];
|
||||
joinTextNodesRange(from: XmlTextNode, to: XmlTextNode): void;
|
||||
joinParagraphs(first: XmlNode, second: XmlNode): void;
|
||||
setSpacePreserveAttribute(node: XmlGeneralNode): void;
|
||||
removeTag(textNode: XmlTextNode): void;
|
||||
}
|
||||
export declare const officeMarkup: OfficeMarkup;
|
||||
export {};
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
declare class W {
|
||||
readonly Paragraph = "w:p";
|
||||
readonly ParagraphProperties = "w:pPr";
|
||||
readonly Run = "w:r";
|
||||
readonly RunProperties = "w:rPr";
|
||||
readonly Text = "w:t";
|
||||
readonly Table = "w:tbl";
|
||||
readonly TableRow = "w:tr";
|
||||
readonly TableCell = "w:tc";
|
||||
readonly NumberProperties = "w:numPr";
|
||||
}
|
||||
declare class A {
|
||||
readonly Paragraph = "a:p";
|
||||
readonly ParagraphProperties = "a:pPr";
|
||||
readonly Run = "a:r";
|
||||
readonly RunProperties = "a:rPr";
|
||||
readonly Text = "a:t";
|
||||
}
|
||||
export declare class OmlNode {
|
||||
static readonly W: W;
|
||||
static readonly A: A;
|
||||
}
|
||||
export declare class OmlAttribute {
|
||||
static readonly SpacePreserve = "xml:space";
|
||||
}
|
||||
export {};
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { Constructor } from "src/types";
|
||||
import { Binary } from "src/utils";
|
||||
import { XmlNode } from "src/xml";
|
||||
import { Zip } from "src/zip";
|
||||
import { RelsFile } from "./relsFile";
|
||||
export declare class OpenXmlPart {
|
||||
readonly rels: RelsFile;
|
||||
readonly path: string;
|
||||
private root;
|
||||
private readonly openedParts;
|
||||
private readonly zip;
|
||||
constructor(path: string, zip: Zip);
|
||||
xmlRoot(): Promise<XmlNode>;
|
||||
getText(): Promise<string>;
|
||||
getContentBinary<T extends Binary>(outputType?: Constructor<T>): Promise<T>;
|
||||
getPartById(relId: string): Promise<OpenXmlPart>;
|
||||
getFirstPartByType(type: string): Promise<OpenXmlPart>;
|
||||
getPartsByType(type: string): Promise<OpenXmlPart[]>;
|
||||
save(binaryContent?: Binary): Promise<void>;
|
||||
private openPart;
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { XmlGeneralNode } from "src/xml";
|
||||
export declare const RelType: Readonly<{
|
||||
readonly Package: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
||||
readonly MainDocument: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
|
||||
readonly Header: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
||||
readonly Footer: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";
|
||||
readonly Styles: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
|
||||
readonly SharedStrings: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings";
|
||||
readonly Link: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
||||
readonly Image: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
||||
readonly Chart: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
|
||||
readonly ChartColors: "http://schemas.microsoft.com/office/2011/relationships/chartColorStyle";
|
||||
readonly Worksheet: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
|
||||
readonly Table: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table";
|
||||
}>;
|
||||
export type RelTargetMode = 'Internal' | 'External';
|
||||
export declare class Relationship {
|
||||
static fromXml(xml: XmlGeneralNode): Relationship;
|
||||
static normalizeRelTarget(target: string): string;
|
||||
id: string;
|
||||
type: string;
|
||||
target: string;
|
||||
targetMode: RelTargetMode;
|
||||
constructor(initial?: Partial<Relationship>);
|
||||
toXml(): XmlGeneralNode;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { Zip } from "src/zip";
|
||||
import { Relationship, RelTargetMode } from "./relationship";
|
||||
export declare class RelsFile {
|
||||
private rels;
|
||||
private relTargets;
|
||||
private nextRelId;
|
||||
private readonly partDir;
|
||||
private readonly relsFilePath;
|
||||
private readonly zip;
|
||||
constructor(partPath: string, zip: Zip);
|
||||
add(relTarget: string, relType: string, relTargetMode?: RelTargetMode): Promise<string>;
|
||||
list(): Promise<Relationship[]>;
|
||||
absoluteTargetPath(relTarget: string): string;
|
||||
save(): Promise<void>;
|
||||
private getNextRelId;
|
||||
private parseRelsFile;
|
||||
private getRelTargetKey;
|
||||
private createRootNode;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { Constructor } from "src/types";
|
||||
import { Binary } from "src/utils";
|
||||
import { Zip } from "src/zip";
|
||||
import { OpenXmlPart } from "./openXmlPart";
|
||||
export declare class Xlsx {
|
||||
static load(file: Binary): Promise<Xlsx>;
|
||||
static open(zip: Zip): Promise<Xlsx>;
|
||||
private static getMainDocumentPath;
|
||||
readonly mainDocument: OpenXmlPart;
|
||||
private readonly _parts;
|
||||
private readonly zip;
|
||||
get rawZipFile(): Zip;
|
||||
private constructor();
|
||||
export<T extends Binary>(outputType?: Constructor<T>): Promise<T>;
|
||||
private saveXmlChanges;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { OpenXmlPart } from "src/office/openXmlPart";
|
||||
import { XmlNode } from "src/xml";
|
||||
import { ChartType } from "./chartData";
|
||||
export interface SeriesAccentColor {
|
||||
name: string;
|
||||
lumMod: string;
|
||||
lumOff: string;
|
||||
}
|
||||
export declare class ChartColors {
|
||||
static load(chartPart: OpenXmlPart): Promise<ChartColors>;
|
||||
private accents;
|
||||
private variations;
|
||||
private initialized;
|
||||
private readonly chartPart;
|
||||
private constructor();
|
||||
setSeriesColor(chartType: ChartType, seriesNode: XmlNode, isNewSeries: boolean, color: string | number): void;
|
||||
private recurseSetColor;
|
||||
private setAccentColor;
|
||||
private getAccentColorConfig;
|
||||
private init;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { PluginContent } from "src/plugins/pluginContent";
|
||||
import { ChartData } from "./chartData";
|
||||
export type ChartContent = ChartPluginContent & ChartData;
|
||||
interface ChartPluginContent extends PluginContent {
|
||||
_type: 'chart';
|
||||
title?: string;
|
||||
}
|
||||
export {};
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
export type ChartData = StandardChartData | ScatterChartData | BubbleChartData;
|
||||
export interface StandardChartData {
|
||||
categories: Categories;
|
||||
series: Series[];
|
||||
}
|
||||
export interface ScatterChartData {
|
||||
series: ScatterSeries[];
|
||||
}
|
||||
export interface BubbleChartData {
|
||||
series: BubbleSeries[];
|
||||
}
|
||||
export type Categories = NumericCategories | StringCategories | DateCategories;
|
||||
export interface NumericCategories {
|
||||
formatCode?: NumberingFormat;
|
||||
names: number[];
|
||||
}
|
||||
export interface StringCategories {
|
||||
names: string[];
|
||||
}
|
||||
export interface DateCategories {
|
||||
formatCode?: DateTimeFormat;
|
||||
names: Date[];
|
||||
}
|
||||
export interface Series {
|
||||
name?: string;
|
||||
color?: string;
|
||||
values: number[];
|
||||
}
|
||||
export interface ScatterSeries {
|
||||
name?: string;
|
||||
color?: string;
|
||||
values: ScatterValue[];
|
||||
}
|
||||
export interface ScatterValue {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
export interface BubbleSeries {
|
||||
name?: string;
|
||||
color?: string;
|
||||
values: BubbleValue[];
|
||||
}
|
||||
export interface BubbleValue extends ScatterValue {
|
||||
size: number;
|
||||
}
|
||||
export declare const chartTypes: Readonly<{
|
||||
readonly area3DChart: "c:area3DChart";
|
||||
readonly areaChart: "c:areaChart";
|
||||
readonly bar3DChart: "c:bar3DChart";
|
||||
readonly barChart: "c:barChart";
|
||||
readonly line3DChart: "c:line3DChart";
|
||||
readonly lineChart: "c:lineChart";
|
||||
readonly doughnutChart: "c:doughnutChart";
|
||||
readonly ofPieChart: "c:ofPieChart";
|
||||
readonly pie3DChart: "c:pie3DChart";
|
||||
readonly pieChart: "c:pieChart";
|
||||
readonly scatterChart: "c:scatterChart";
|
||||
readonly bubbleChart: "c:bubbleChart";
|
||||
}>;
|
||||
export type ChartType = typeof chartTypes[keyof typeof chartTypes];
|
||||
export declare const NumberingFormatValues: Readonly<{
|
||||
readonly General: "General";
|
||||
readonly Integer: "0";
|
||||
readonly Decimal_2Places: "0.00";
|
||||
readonly ThousandsSeparator: "#,##0";
|
||||
readonly ThousandsSeparator_2DecimalPlaces: "#,##0.00";
|
||||
readonly ThousandsSeparator_ParenthesesForNegatives: "#,##0 ;(#,##0)";
|
||||
readonly ThousandsSeparator_RedNegatives: "#,##0 ;[Red](#,##0)";
|
||||
readonly ThousandsSeparator_2DecimalPlaces_ParenthesesForNegatives: "#,##0.00;(#,##0.00)";
|
||||
readonly ThousandsSeparator_2DecimalPlaces_RedNegatives: "#,##0.00;[Red](#,##0.00)";
|
||||
readonly Percentage: "0%";
|
||||
readonly Percentage_2DecimalPlaces: "0.00%";
|
||||
readonly Scientific: "0.00E+00";
|
||||
readonly Scientific_1DecimalPlace: "##0.0E+0";
|
||||
readonly Fraction_SingleDigit: "# ?/?";
|
||||
readonly Fraction_DoubleDigit: "# ??/?";
|
||||
readonly Text: "@";
|
||||
}>;
|
||||
export type NumberingFormat = typeof NumberingFormatValues[keyof typeof NumberingFormatValues];
|
||||
export declare const DateTimeFormatValues: Readonly<{
|
||||
readonly General: "General";
|
||||
readonly Date_Short: "mm-dd-yy";
|
||||
readonly Date_DayMonthYear: "d-mmm-yy";
|
||||
readonly Date_DayMonth: "d-mmm";
|
||||
readonly Date_MonthYear: "mmm-yy";
|
||||
readonly Time_12Hour: "h:mm AM/PM";
|
||||
readonly Time_12Hour_WithSeconds: "h:mm:ss AM/PM";
|
||||
readonly Time_24Hour: "h:mm";
|
||||
readonly Time_24Hour_WithSeconds: "h:mm:ss";
|
||||
readonly DateTime_Short: "m/d/yy h:mm";
|
||||
readonly Time_MinutesSeconds: "mm:ss";
|
||||
readonly Time_ElapsedHoursMinutesSeconds: "[h]:mm:ss";
|
||||
readonly Time_CompactMinutesSecondsWithDecimal: "mmss.0";
|
||||
readonly Text: "@";
|
||||
}>;
|
||||
export type DateTimeFormat = typeof DateTimeFormatValues[keyof typeof DateTimeFormatValues];
|
||||
export declare const formatIds: Readonly<{
|
||||
General: 0;
|
||||
"0": 1;
|
||||
"0.00": 2;
|
||||
"#,##0": 3;
|
||||
"#,##0.00": 4;
|
||||
"0%": 9;
|
||||
"0.00%": 10;
|
||||
"0.00E+00": 11;
|
||||
"# ?/?": 12;
|
||||
"# ??/?": 13;
|
||||
"mm-dd-yy": 14;
|
||||
"d-mmm-yy": 15;
|
||||
"d-mmm": 16;
|
||||
"mmm-yy": 17;
|
||||
"h:mm AM/PM": 18;
|
||||
"h:mm:ss AM/PM": 19;
|
||||
"h:mm": 20;
|
||||
"h:mm:ss": 21;
|
||||
"m/d/yy h:mm": 22;
|
||||
"#,##0 ;(#,##0)": 37;
|
||||
"#,##0 ;[Red](#,##0)": 38;
|
||||
"#,##0.00;(#,##0.00)": 39;
|
||||
"#,##0.00;[Red](#,##0.00)": 40;
|
||||
"mm:ss": 45;
|
||||
"[h]:mm:ss": 46;
|
||||
"mmss.0": 47;
|
||||
"##0.0E+0": 48;
|
||||
"@": 49;
|
||||
}>;
|
||||
export type FormatCode = NumberingFormat | DateTimeFormat;
|
||||
export declare function chartFriendlyName(chartType: ChartType): string;
|
||||
export declare function isStandardChartType(chartType: ChartType): boolean;
|
||||
export declare function isScatterChartType(chartType: ChartType): boolean;
|
||||
export declare function isBubbleChartType(chartType: ChartType): boolean;
|
||||
export declare function isStandardChartData(chartData: ChartData): chartData is StandardChartData;
|
||||
export declare function isScatterChartData(chartData: ChartData): chartData is ScatterChartData;
|
||||
export declare function isBubbleChartData(chartData: ChartData): chartData is BubbleChartData;
|
||||
export declare function isStringCategories(categories: Categories): categories is StringCategories;
|
||||
export declare function isDateCategories(categories: Categories): categories is DateCategories;
|
||||
export declare function formatCode(categories: Categories): FormatCode;
|
||||
export declare function scatterXValues(series: ScatterSeries[]): number[];
|
||||
export declare function scatterYValues(xValues: number[], series: ScatterSeries): number[];
|
||||
export declare function bubbleSizeValues(xValues: number[], series: BubbleSeries): number[];
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { ChartData, ChartType } from "./chartData";
|
||||
export declare function validateChartData(chartType: ChartType, chartData: ChartData): void;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { ScopeData, Tag, TemplateContext } from "src/compilation";
|
||||
import { TemplatePlugin } from "src/plugins/templatePlugin";
|
||||
export declare class ChartPlugin extends TemplatePlugin {
|
||||
readonly contentType = "chart";
|
||||
simpleTagReplacements(tag: Tag, data: ScopeData, context: TemplateContext): Promise<void>;
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './chartContent';
|
||||
export * from './chartPlugin';
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { OpenXmlPart } from "src/office";
|
||||
import { ChartData } from "./chartData";
|
||||
export declare function updateChart(chartPart: OpenXmlPart, chartData: ChartData): Promise<void>;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { TemplatePlugin } from "./templatePlugin";
|
||||
export declare function createDefaultPlugins(): TemplatePlugin[];
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { MimeType } from '../../mimeType';
|
||||
import { Binary } from '../../utils';
|
||||
import { PluginContent } from '../pluginContent';
|
||||
export type ImageFormat = typeof MimeType.Jpeg | typeof MimeType.Png | typeof MimeType.Gif | typeof MimeType.Bmp | typeof MimeType.Svg;
|
||||
export interface ImageContent extends PluginContent {
|
||||
_type: 'image';
|
||||
source: Binary;
|
||||
format: ImageFormat;
|
||||
width: number;
|
||||
height: number;
|
||||
altText?: string;
|
||||
transparencyPercent?: number;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { ScopeData, Tag, TemplateContext } from "src/compilation";
|
||||
import { TemplatePlugin } from "src/plugins/templatePlugin";
|
||||
export declare class ImagePlugin extends TemplatePlugin {
|
||||
readonly contentType = "image";
|
||||
simpleTagReplacements(tag: Tag, data: ScopeData, context: TemplateContext): Promise<void>;
|
||||
private getNextImageId;
|
||||
private createMarkup;
|
||||
private docProperties;
|
||||
private pictureMarkup;
|
||||
private transparencyMarkup;
|
||||
private pixelsToEmu;
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './imageContent';
|
||||
export * from './imagePlugin';
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
export * from './image';
|
||||
export * from './link';
|
||||
export * from './loop';
|
||||
export * from './rawXml';
|
||||
export * from './text';
|
||||
export * from './defaultPlugins';
|
||||
export * from './pluginContent';
|
||||
export * from './templatePlugin';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './linkContent';
|
||||
export * from './linkPlugin';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { PluginContent } from '../pluginContent';
|
||||
export interface LinkContent extends PluginContent {
|
||||
_type: 'link';
|
||||
text?: string;
|
||||
target: string;
|
||||
tooltip?: string;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { ScopeData, Tag, TemplateContext } from "src/compilation";
|
||||
import { TemplatePlugin } from "src/plugins/templatePlugin";
|
||||
export declare class LinkPlugin extends TemplatePlugin {
|
||||
readonly contentType = "link";
|
||||
simpleTagReplacements(tag: Tag, data: ScopeData, context: TemplateContext): Promise<void>;
|
||||
private generateMarkup;
|
||||
private insertHyperlinkNode;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './loopPlugin';
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { ScopeData, Tag, TemplateContext } from "src/compilation";
|
||||
import { PluginUtilities, TemplatePlugin } from "src/plugins/templatePlugin";
|
||||
export declare const LOOP_CONTENT_TYPE = "loop";
|
||||
export declare class LoopPlugin extends TemplatePlugin {
|
||||
readonly contentType = "loop";
|
||||
private readonly loopStrategies;
|
||||
setUtilities(utilities: PluginUtilities): void;
|
||||
containerTagReplacements(tags: Tag[], data: ScopeData, context: TemplateContext): Promise<void>;
|
||||
private repeat;
|
||||
private compile;
|
||||
private updatePathBefore;
|
||||
private updatePathAfter;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export declare const LoopOver: Readonly<{
|
||||
readonly Row: "row";
|
||||
readonly Column: "column";
|
||||
readonly Content: "content";
|
||||
}>;
|
||||
export type LoopOver = typeof LoopOver[keyof typeof LoopOver];
|
||||
export declare class LoopTagOptions {
|
||||
loopOver: LoopOver;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { Tag } from "src/compilation";
|
||||
import { XmlNode } from "src/xml";
|
||||
export interface ILoopStrategy {
|
||||
isApplicable(openTag: Tag, closeTag: Tag, isCondition: boolean): boolean;
|
||||
splitBefore(openTag: Tag, closeTag: Tag): SplitBeforeResult;
|
||||
mergeBack(compiledNodes: XmlNode[][], firstNode: XmlNode, lastNode: XmlNode): void;
|
||||
}
|
||||
export interface SplitBeforeResult {
|
||||
firstNode: XmlNode;
|
||||
nodesToRepeat: XmlNode[];
|
||||
lastNode: XmlNode;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export * from './iLoopStrategy';
|
||||
export * from './loopListStrategy';
|
||||
export * from './loopParagraphStrategy';
|
||||
export * from './loopTableColumnsStrategy';
|
||||
export * from './loopTableRowsStrategy';
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { Tag } from "src/compilation";
|
||||
import { XmlNode } from "src/xml";
|
||||
import { ILoopStrategy, SplitBeforeResult } from "./iLoopStrategy";
|
||||
export declare class LoopListStrategy implements ILoopStrategy {
|
||||
isApplicable(openTag: Tag, closeTag: Tag, isCondition: boolean): boolean;
|
||||
splitBefore(openTag: Tag, closeTag: Tag): SplitBeforeResult;
|
||||
mergeBack(paragraphGroups: XmlNode[][], firstParagraph: XmlNode, lastParagraphs: XmlNode): void;
|
||||
}
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { Tag } from "src/compilation";
|
||||
import { XmlNode } from "src/xml";
|
||||
import { ILoopStrategy, SplitBeforeResult } from "./iLoopStrategy";
|
||||
export declare class LoopParagraphStrategy implements ILoopStrategy {
|
||||
isApplicable(openTag: Tag, closeTag: Tag, isCondition: boolean): boolean;
|
||||
splitBefore(openTag: Tag, closeTag: Tag): SplitBeforeResult;
|
||||
mergeBack(middleParagraphs: XmlNode[][], firstParagraph: XmlNode, lastParagraph: XmlNode): void;
|
||||
}
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
import { Tag } from "src/compilation";
|
||||
import { XmlNode } from "src/xml";
|
||||
import { ILoopStrategy, SplitBeforeResult } from "./iLoopStrategy";
|
||||
export declare class LoopTableColumnsStrategy implements ILoopStrategy {
|
||||
isApplicable(openTag: Tag, closeTag: Tag, isCondition: boolean): boolean;
|
||||
splitBefore(openTag: Tag, closeTag: Tag): SplitBeforeResult;
|
||||
mergeBack(columnsWrapperGroups: XmlNode[][], firstCell: XmlNode, lastCell: XmlNode): void;
|
||||
private extractColumns;
|
||||
private insertColumnAfterIndex;
|
||||
private removeColumn;
|
||||
private getColumnIndex;
|
||||
private getColumnByIndex;
|
||||
}
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { Tag } from "src/compilation";
|
||||
import { XmlNode } from "src/xml";
|
||||
import { ILoopStrategy, SplitBeforeResult } from "./iLoopStrategy";
|
||||
export declare class LoopTableRowsStrategy implements ILoopStrategy {
|
||||
isApplicable(openTag: Tag, closeTag: Tag, isCondition: boolean): boolean;
|
||||
splitBefore(openTag: Tag, closeTag: Tag): SplitBeforeResult;
|
||||
mergeBack(rowGroups: XmlNode[][], firstRow: XmlNode, lastRow: XmlNode): void;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export interface PluginContent {
|
||||
_type: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
export declare const PluginContent: {
|
||||
isPluginContent(content: unknown): content is PluginContent;
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './rawXmlContent';
|
||||
export * from './rawXmlPlugin';
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { PluginContent } from '../pluginContent';
|
||||
export interface RawXmlContent extends PluginContent {
|
||||
_type: 'rawXml';
|
||||
xml: string;
|
||||
replaceParagraph?: boolean;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { ScopeData, Tag } from "src/compilation";
|
||||
import { TemplatePlugin } from "src/plugins/templatePlugin";
|
||||
export declare class RawXmlPlugin extends TemplatePlugin {
|
||||
readonly contentType = "rawXml";
|
||||
simpleTagReplacements(tag: Tag, data: ScopeData): void;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { ScopeData, Tag, TemplateCompiler, TemplateContext } from "../compilation";
|
||||
export interface PluginUtilities {
|
||||
compiler: TemplateCompiler;
|
||||
}
|
||||
export declare abstract class TemplatePlugin {
|
||||
abstract readonly contentType: string;
|
||||
protected utilities: PluginUtilities;
|
||||
setUtilities(utilities: PluginUtilities): void;
|
||||
simpleTagReplacements(tag: Tag, data: ScopeData, context: TemplateContext): void | Promise<void>;
|
||||
containerTagReplacements(tags: Tag[], data: ScopeData, context: TemplateContext): void | Promise<void>;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './textPlugin';
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { ScopeData, Tag } from "src/compilation";
|
||||
import { TemplatePlugin } from "src/plugins/templatePlugin";
|
||||
export declare const TEXT_CONTENT_TYPE = "text";
|
||||
export declare class TextPlugin extends TemplatePlugin {
|
||||
readonly contentType = "text";
|
||||
simpleTagReplacements(tag: Tag, data: ScopeData): void;
|
||||
private replaceSingleLine;
|
||||
private replaceMultiLine;
|
||||
private getLineBreak;
|
||||
private createOfficeTextNode;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { PluginContent } from './plugins';
|
||||
export type PrimitiveTemplateContent = string | number | boolean;
|
||||
export type TemplateContent = PrimitiveTemplateContent | PluginContent;
|
||||
export interface TemplateData {
|
||||
[tagName: string]: TemplateContent | TemplateData | TemplateData[];
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { Tag } from "./compilation";
|
||||
import { OpenXmlPart } from "./office";
|
||||
import { TemplateData } from "./templateData";
|
||||
import { TemplateHandlerOptions } from "./templateHandlerOptions";
|
||||
import { Binary } from "./utils";
|
||||
import { XmlNode } from "./xml";
|
||||
export declare class TemplateHandler {
|
||||
readonly version: string;
|
||||
private readonly compiler;
|
||||
private readonly options;
|
||||
constructor(options?: TemplateHandlerOptions);
|
||||
process<T extends Binary>(templateFile: T, data: TemplateData): Promise<T>;
|
||||
parseTags(templateFile: Binary): Promise<Tag[]>;
|
||||
getText(docxFile: Binary, relType?: string): Promise<string>;
|
||||
getXml(docxFile: Binary, relType?: string): Promise<XmlNode>;
|
||||
getParts(docxFile: Binary, relType: string): Promise<OpenXmlPart[]>;
|
||||
private callExtensions;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { ScopeDataResolver } from './compilation';
|
||||
import { Delimiters } from './delimiters';
|
||||
import { ExtensionOptions } from './extensions';
|
||||
import { TemplatePlugin } from './plugins';
|
||||
export declare class TemplateHandlerOptions {
|
||||
plugins?: TemplatePlugin[];
|
||||
skipEmptyTags?: boolean;
|
||||
defaultContentType?: string;
|
||||
containerContentType?: string;
|
||||
delimiters?: Partial<Delimiters>;
|
||||
maxXmlDepth?: number;
|
||||
extensions?: ExtensionOptions;
|
||||
scopeDataResolver?: ScopeDataResolver;
|
||||
constructor(initial?: Partial<TemplateHandlerOptions>);
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export type IMap<T> = Record<string, T>;
|
||||
export interface Constructor<T> {
|
||||
new (...args: any[]): T;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { IMap } from '../types';
|
||||
export type ItemMapper<TIn, TOut = string> = (item: TIn, index: number) => TOut;
|
||||
export declare function pushMany<T>(destArray: T[], items: T[]): void;
|
||||
export declare function first<T>(array: T[]): T;
|
||||
export declare function last<T>(array: T[]): T;
|
||||
export declare function toDictionary<TIn, TOut = TIn>(array: TIn[], keySelector: ItemMapper<TIn>, valueSelector?: ItemMapper<TIn, TOut>): IMap<TOut>;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export declare class Base64 {
|
||||
static encode(str: string): string;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { Constructor } from '../types';
|
||||
export type Binary = Blob | Buffer | ArrayBuffer;
|
||||
export declare const Binary: {
|
||||
isBlob(binary: unknown): binary is Blob;
|
||||
isArrayBuffer(binary: unknown): binary is ArrayBuffer;
|
||||
isBuffer(binary: unknown): binary is Buffer;
|
||||
isBlobConstructor(binaryType: Constructor<unknown>): binaryType is Constructor<Blob>;
|
||||
isArrayBufferConstructor(binaryType: Constructor<unknown>): binaryType is Constructor<ArrayBuffer>;
|
||||
isBufferConstructor(binaryType: Constructor<unknown>): binaryType is Constructor<Buffer>;
|
||||
toBase64(binary: Binary): Promise<string>;
|
||||
};
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export * from './array';
|
||||
export * from './base64';
|
||||
export * from './binary';
|
||||
export * from './number';
|
||||
export * from './path';
|
||||
export * from './regex';
|
||||
export * from './sha1';
|
||||
export * from './txt';
|
||||
export * from './types';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export declare function isNumber(value: unknown): value is number;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export declare class Path {
|
||||
static getFilename(path: string): string;
|
||||
static getDirectory(path: string): string;
|
||||
static combine(...parts: string[]): string;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export declare class Regex {
|
||||
static escape(str: string): string;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export declare function sha1(msg: string): string;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export declare function stringValue(val: unknown): string;
|
||||
export declare function normalizeDoubleQuotes(text: string): string;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { Constructor } from '../types';
|
||||
export declare function inheritsFrom(derived: Constructor<any>, base: Constructor<any>): boolean;
|
||||
export declare function isPromiseLike<T>(candidate: unknown): candidate is PromiseLike<T>;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export * from "./xml";
|
||||
export * from "./xmlDepthTracker";
|
||||
export * from "./xmlNode";
|
||||
export * from "./xmlTreeIterator";
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
import { XmlGeneralNode, XmlNode } from "./xmlNode";
|
||||
import { XmlCommentNode } from "./xmlNode";
|
||||
import { XmlTextNode } from "./xmlNode";
|
||||
import type { IMap } from "src/types";
|
||||
export type XmlNodePredicate = (node: XmlNode) => boolean;
|
||||
export declare class XmlUtils {
|
||||
readonly parser: Parser;
|
||||
readonly create: Create;
|
||||
readonly query: Query;
|
||||
readonly modify: Modify;
|
||||
}
|
||||
declare class Parser {
|
||||
private static xmlFileHeader;
|
||||
private static readonly parser;
|
||||
parse(str: string): XmlNode;
|
||||
domParse(str: string): Document;
|
||||
encodeValue(str: string): string;
|
||||
serializeNode(node: XmlNode): string;
|
||||
serializeFile(xmlNode: XmlNode): string;
|
||||
}
|
||||
interface XmlGeneralNodeInit {
|
||||
attributes?: IMap<string>;
|
||||
childNodes?: XmlNode[];
|
||||
}
|
||||
declare class Create {
|
||||
textNode(text?: string): XmlTextNode;
|
||||
generalNode(name: string, init?: XmlGeneralNodeInit): XmlGeneralNode;
|
||||
commentNode(text?: string): XmlCommentNode;
|
||||
cloneNode<T extends XmlNode>(node: T, deep: boolean): T;
|
||||
fromDomNode(domNode: Node): XmlNode;
|
||||
}
|
||||
declare class Query {
|
||||
isTextNode(node: XmlNode): node is XmlTextNode;
|
||||
isGeneralNode(node: XmlNode): node is XmlGeneralNode;
|
||||
isCommentNode(node: XmlNode): node is XmlCommentNode;
|
||||
lastTextChild(node: XmlNode, createIfMissing?: boolean): XmlTextNode;
|
||||
findParent(node: XmlNode, predicate: (node: XmlNode) => boolean): XmlNode;
|
||||
findParentByName(node: XmlNode, nodeName: string): XmlNode;
|
||||
findChild(node: XmlNode, predicate: (node: XmlNode) => boolean): XmlNode;
|
||||
findChildByName(node: XmlNode, childName: string): XmlNode;
|
||||
siblingsInRange(firstNode: XmlNode, lastNode: XmlNode): XmlNode[];
|
||||
descendants(node: XmlNode, maxDepth: number, predicate: XmlNodePredicate): XmlNode[];
|
||||
}
|
||||
declare class Modify {
|
||||
insertBefore(newNode: XmlNode, referenceNode: XmlNode): void;
|
||||
insertAfter(newNode: XmlNode, referenceNode: XmlNode): void;
|
||||
insertChild(parent: XmlNode, child: XmlNode, childIndex: number): void;
|
||||
appendChild(parent: XmlNode, child: XmlNode): void;
|
||||
remove(node: XmlNode): void;
|
||||
removeChild(parent: XmlNode, child: XmlNode): XmlNode;
|
||||
removeChild(parent: XmlNode, childIndex: number): XmlNode;
|
||||
removeChildren(parent: XmlNode, predicate: (child: XmlNode) => boolean): void;
|
||||
removeSiblings(from: XmlNode, to: XmlNode): XmlNode[];
|
||||
splitByChild(parent: XmlNode, child: XmlNode, removeChild: boolean): [XmlNode, XmlNode];
|
||||
removeEmptyTextNodes(node: XmlNode): void;
|
||||
}
|
||||
export declare const xml: XmlUtils;
|
||||
export {};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export declare class XmlDepthTracker {
|
||||
private depth;
|
||||
private readonly maxDepth;
|
||||
constructor(maxDepth: number);
|
||||
increment(): void;
|
||||
decrement(): void;
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { IMap } from "src/types";
|
||||
export declare const XmlNodeType: Readonly<{
|
||||
readonly Text: "Text";
|
||||
readonly General: "General";
|
||||
readonly Comment: "Comment";
|
||||
}>;
|
||||
export type XmlNodeType = typeof XmlNodeType[keyof typeof XmlNodeType];
|
||||
export type XmlNode = XmlTextNode | XmlGeneralNode | XmlCommentNode;
|
||||
export interface XmlNodeBase {
|
||||
nodeType: XmlNodeType;
|
||||
nodeName: string;
|
||||
parentNode?: XmlNode;
|
||||
childNodes?: XmlNode[];
|
||||
nextSibling?: XmlNode;
|
||||
}
|
||||
export declare const TEXT_NODE_NAME = "#text";
|
||||
export declare const COMMENT_NODE_NAME = "#comment";
|
||||
export interface XmlTextNode extends XmlNodeBase {
|
||||
nodeType: typeof XmlNodeType.Text;
|
||||
nodeName: typeof TEXT_NODE_NAME;
|
||||
textContent: string;
|
||||
}
|
||||
export interface XmlCommentNode extends XmlNodeBase {
|
||||
nodeType: typeof XmlNodeType.Comment;
|
||||
nodeName: typeof COMMENT_NODE_NAME;
|
||||
commentContent: string;
|
||||
}
|
||||
export interface XmlGeneralNode extends XmlNodeBase {
|
||||
nodeType: typeof XmlNodeType.General;
|
||||
attributes?: IMap<string>;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { XmlNode } from "./xmlNode";
|
||||
export declare class XmlTreeIterator<T extends XmlNode = XmlNode> {
|
||||
get node(): T;
|
||||
private _current;
|
||||
private readonly depthTracker;
|
||||
constructor(initial: XmlNode, maxDepth: number);
|
||||
next(): XmlNode;
|
||||
setCurrent(node: XmlNode): void;
|
||||
private findNextNode;
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './zip';
|
||||
export * from './zipObject';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import JSZip from 'jszip';
|
||||
import { Constructor } from '../types';
|
||||
import { Binary } from '../utils';
|
||||
export declare class JsZipHelper {
|
||||
static toJsZipOutputType(binary: Binary): JSZip.OutputType;
|
||||
static toJsZipOutputType(binaryType: Constructor<Binary>): JSZip.OutputType;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { Constructor } from '../types';
|
||||
import { Binary } from '../utils';
|
||||
import { ZipObject } from './zipObject';
|
||||
export declare class Zip {
|
||||
static load(file: Binary): Promise<Zip>;
|
||||
private readonly zip;
|
||||
private readonly binaryFormat;
|
||||
private constructor();
|
||||
getFile(path: string): ZipObject;
|
||||
setFile(path: string, content: string | Binary): void;
|
||||
isFileExist(path: string): boolean;
|
||||
listFiles(): string[];
|
||||
export<T extends Binary>(outputType?: Constructor<T>): Promise<T>;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import JSZip from 'jszip';
|
||||
import { Constructor } from '../types';
|
||||
import { Binary } from '../utils';
|
||||
export declare class ZipObject {
|
||||
get name(): string;
|
||||
set name(value: string);
|
||||
get isDirectory(): boolean;
|
||||
private readonly zipObject;
|
||||
private readonly binaryFormat;
|
||||
constructor(zipObject: JSZip.JSZipObject, binaryFormat: Constructor<Binary>);
|
||||
getContentText(): Promise<string>;
|
||||
getContentBase64(): Promise<string>;
|
||||
getContentBinary<T extends Binary>(outputType?: Constructor<T>): Promise<T>;
|
||||
}
|
||||
Reference in new issue
Block a user