archiyou 0.7.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/LICENSE +201 -0
- package/README.md +215 -0
- package/dist/archiyou.js +35969 -0
- package/dist/index.d.ts +2 -0
- package/dist/src/Annotator.d.ts +55 -0
- package/dist/src/AnnotatorBaseAnnotation.d.ts +16 -0
- package/dist/src/AnnotatorDimensionLine.d.ts +92 -0
- package/dist/src/Bbox.d.ts +126 -0
- package/dist/src/Beams.d.ts +316 -0
- package/dist/src/Brep.d.ts +152 -0
- package/dist/src/Calc.d.ts +48 -0
- package/dist/src/CalcDb.d.ts +33 -0
- package/dist/src/CalcTable.d.ts +60 -0
- package/dist/src/CalcTableIO.d.ts +130 -0
- package/dist/src/CodeParser.d.ts +58 -0
- package/dist/src/ComponentManager.d.ts +33 -0
- package/dist/src/Console.d.ts +34 -0
- package/dist/src/Doc.d.ts +181 -0
- package/dist/src/DocDocument.d.ts +27 -0
- package/dist/src/DocPDFExporter.d.ts +105 -0
- package/dist/src/DocPage.d.ts +75 -0
- package/dist/src/DocPageContainer.d.ts +65 -0
- package/dist/src/DocPageContainerGraphic.d.ts +10 -0
- package/dist/src/DocPageContainerImage.d.ts +21 -0
- package/dist/src/DocPageContainerTable.d.ts +21 -0
- package/dist/src/DocPageContainerText.d.ts +23 -0
- package/dist/src/DocPageContainerTextArea.d.ts +23 -0
- package/dist/src/DocPageContainerView.d.ts +22 -0
- package/dist/src/DocUtils.d.ts +12 -0
- package/dist/src/DocViewSVGManager.d.ts +91 -0
- package/dist/src/Edge.d.ts +190 -0
- package/dist/src/Exporter.d.ts +100 -0
- package/dist/src/Face.d.ts +134 -0
- package/dist/src/GLTFBuilder.d.ts +30 -0
- package/dist/src/IO.d.ts +87 -0
- package/dist/src/LibraryConnector.d.ts +56 -0
- package/dist/src/Make.d.ts +85 -0
- package/dist/src/MakeOperations.d.ts +32 -0
- package/dist/src/OBbox.d.ts +121 -0
- package/dist/src/Obj.d.ts +104 -0
- package/dist/src/OcLoader.d.ts +39 -0
- package/dist/src/ParamManager.d.ts +57 -0
- package/dist/src/ParamManagerOperator.d.ts +68 -0
- package/dist/src/Pipeline.d.ts +20 -0
- package/dist/src/Point.d.ts +88 -0
- package/dist/src/Runner.d.ts +230 -0
- package/dist/src/RunnerComponentImporter.d.ts +71 -0
- package/dist/src/RunnerOps.d.ts +15 -0
- package/dist/src/Script.d.ts +78 -0
- package/dist/src/ScriptOutputManager.d.ts +19 -0
- package/dist/src/ScriptOutputPath.d.ts +48 -0
- package/dist/src/ScriptParam.d.ts +78 -0
- package/dist/src/Selector.d.ts +48 -0
- package/dist/src/Services.d.ts +68 -0
- package/dist/src/Shape.d.ts +628 -0
- package/dist/src/ShapeCollection.d.ts +429 -0
- package/dist/src/Shell.d.ts +48 -0
- package/dist/src/Sketch.d.ts +162 -0
- package/dist/src/Solid.d.ts +54 -0
- package/dist/src/Vector.d.ts +167 -0
- package/dist/src/Vertex.d.ts +57 -0
- package/dist/src/VertexCollection.d.ts +11 -0
- package/dist/src/Wire.d.ts +180 -0
- package/dist/src/constants.d.ts +112 -0
- package/dist/src/decorators.d.ts +27 -0
- package/dist/src/garbageCollection.d.ts +4 -0
- package/dist/src/init.d.ts +5 -0
- package/dist/src/internal.d.ts +67 -0
- package/dist/src/models.d.ts +40 -0
- package/dist/src/typeguards.d.ts +88 -0
- package/dist/src/types.d.ts +944 -0
- package/dist/src/utils.d.ts +140 -0
- package/dist/src/wasm/build-scripts/build_wasm_base64.d.ts +8 -0
- package/dist/src/wasm/index.d.ts +8 -0
- package/dist/src/workerUtils.d.ts +14 -0
- package/dist/wasm/README.md +13 -0
- package/dist/wasm/archiyou-opencascade.d.ts +9933 -0
- package/dist/wasm/archiyou-opencascade.js +16 -0
- package/dist/wasm/archiyou-opencascade.wasm +0 -0
- package/dist/wasm/index.js +32 -0
- package/dist/wasm/node.d.ts +16 -0
- package/dist/wasm/node.js +40 -0
- package/package.json +66 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { ArchiyouApp, AnyShapeOrCollection, PageSide, PageOrientation, ContainerSide, ContainerSizeRelativeTo, ScaleInput, ImageOptions, TextOptions, Brep, ShapeCollection, Container, DocDocument, Page, PageSize, AnyPageContainer, TableContainerOptions, DocPathStyle, ContainerAlignment, ContainerHAlignment, ContainerVAlignment, ContainerPositionLike, DocPDFExporter, DocSettings, DocUnits, DocUnitsWithPerc, PercentageString, ValueWithUnitsString, WidthHeightInput, ContainerTableInput, DocData, DocGraphicInputRect, DocGraphicInputCircle, DocGraphicInputOrthoLine, ContainerBlock, TitleBlockInput, LabelBlockOptions } from './internal';
|
|
2
|
+
export declare class Doc {
|
|
3
|
+
DOC_DEFAULT_NAME: string;
|
|
4
|
+
DOC_UNITS_DEFAULT: DocUnits;
|
|
5
|
+
PAGE_SIZE_DEFAULT: PageSize;
|
|
6
|
+
PAGE_ORIENTATION_DEFAULT: PageOrientation;
|
|
7
|
+
CONTENT_ALIGN_DEFAULT: ContainerAlignment;
|
|
8
|
+
TEXT_SIZE_DEFAULT: string;
|
|
9
|
+
TYPES_WITHOUT_CAPTION: string[];
|
|
10
|
+
_ay: ArchiyouApp;
|
|
11
|
+
_settings: DocSettings;
|
|
12
|
+
_brep: Brep;
|
|
13
|
+
_calc: any;
|
|
14
|
+
_pdfExporter: DocPDFExporter;
|
|
15
|
+
_docs: Array<DocDocument>;
|
|
16
|
+
_activeDoc: DocDocument;
|
|
17
|
+
_lastBlock: ContainerBlock;
|
|
18
|
+
_activePage: Page;
|
|
19
|
+
_activeContainer: AnyPageContainer;
|
|
20
|
+
_assetsCache: Record<string, any>;
|
|
21
|
+
constructor(settings?: DocSettings, ay?: ArchiyouApp);
|
|
22
|
+
hasDocs(): boolean;
|
|
23
|
+
setArchiyou(ay?: ArchiyouApp): void;
|
|
24
|
+
/** Reset state of Doc instance */
|
|
25
|
+
reset(): void;
|
|
26
|
+
_setDefaults(): Doc;
|
|
27
|
+
/** Execute pipeline for docs in worker scope
|
|
28
|
+
* @param include list of docs to include (if empty all)
|
|
29
|
+
* @param exclude list of docs to include (if empty exclude none)
|
|
30
|
+
*
|
|
31
|
+
* NOTE: this is pretty black magic. We should give more structure to Workers, execution and scopes.
|
|
32
|
+
*/
|
|
33
|
+
executePipelines(include?: Array<string>, exclude?: Array<string>): void;
|
|
34
|
+
/** Make a new DocDocument with optionally a name */
|
|
35
|
+
create(name?: string): Doc;
|
|
36
|
+
/** Set name of current document (might be the default) */
|
|
37
|
+
name(name: string): Doc;
|
|
38
|
+
/** Check if there is an active DocDocument, otherwise create a default one */
|
|
39
|
+
checkAndMakeDefaultDoc(): DocDocument;
|
|
40
|
+
/** Check if there is an active Page, otherwise create a default one
|
|
41
|
+
* This avoid errors when user forgets to create a page
|
|
42
|
+
*/
|
|
43
|
+
_getOrMakeActivePage(): Page;
|
|
44
|
+
/** Set Unit for active DocDocument: 'mm','cm' or 'inch' */
|
|
45
|
+
units(units: DocUnits): Doc;
|
|
46
|
+
/** Set general page ISO size (A0,A4 etc) for current doc */
|
|
47
|
+
pageSize(size: PageSize): Doc;
|
|
48
|
+
/** Set general page ISO size (A0,A4 etc) for current doc */
|
|
49
|
+
pageOrientation(o: PageOrientation): Doc;
|
|
50
|
+
/** Add a new page to the doc with given name */
|
|
51
|
+
page(name: string): Doc;
|
|
52
|
+
/** Define script that is executed before active DocDocument is generated */
|
|
53
|
+
pipeline(fn: () => any): Doc;
|
|
54
|
+
/** Set size of active Page */
|
|
55
|
+
size(size: PageSize): Doc;
|
|
56
|
+
/** Set padding of active Page (width (left and right) and height (top and bottom))
|
|
57
|
+
* Use relative width/height ([0-1]), number with percentage (5%) or number with real units ('1cm','0.5"')
|
|
58
|
+
*/
|
|
59
|
+
padding(w: WidthHeightInput, h?: WidthHeightInput): Doc;
|
|
60
|
+
/** Set orientation ('landscape' or 'portrait') of active page */
|
|
61
|
+
orientation(o: PageOrientation): Doc;
|
|
62
|
+
/** Add View Container to active Page */
|
|
63
|
+
view(name?: string, shapes?: ShapeCollection): Doc;
|
|
64
|
+
/** Add Image Container to active Page */
|
|
65
|
+
image(url: string, options?: ImageOptions): Doc;
|
|
66
|
+
/** Add Text line to active Page */
|
|
67
|
+
text(text: string | number, options?: TextOptions): Doc;
|
|
68
|
+
/** Add multiline text area */
|
|
69
|
+
textarea(text: string | number, options?: TextOptions): Doc;
|
|
70
|
+
/** Add table to active Page
|
|
71
|
+
* @param input name of Calc table
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
table(nameOrData: ContainerTableInput, options?: TableContainerOptions): Doc;
|
|
75
|
+
/** Draw rect graphic on current page
|
|
76
|
+
* @param ?input { size (when width=height), width, height, round }
|
|
77
|
+
*/
|
|
78
|
+
rect(input?: number | string | DocGraphicInputRect, style?: DocPathStyle): this;
|
|
79
|
+
/** Draw circle graphic on current page
|
|
80
|
+
* @param input { size (=radius), radius }
|
|
81
|
+
*/
|
|
82
|
+
circle(input?: number | string | DocGraphicInputCircle, style?: DocPathStyle): Doc;
|
|
83
|
+
/** Draw ortho (horizontal|vertical) line graphic on current page
|
|
84
|
+
* @param input string (10mm), number (10, with default units, mm) or object with options
|
|
85
|
+
* @param thickness strokeWidth
|
|
86
|
+
* @param color
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
_oline(type: 'h' | 'v', input?: string | number | DocGraphicInputOrthoLine, thickness?: number | string, color?: string): Doc;
|
|
90
|
+
hline(input?: string | number | DocGraphicInputOrthoLine, thickness?: number | string, color?: string): Doc;
|
|
91
|
+
vline(input?: string | number | DocGraphicInputOrthoLine, thickness?: number | string, color?: string): Doc;
|
|
92
|
+
/** Place default title block
|
|
93
|
+
* @param data:TitleBlockInput
|
|
94
|
+
*/
|
|
95
|
+
titleblock(data?: TitleBlockInput): this;
|
|
96
|
+
_getParamSummary(): string;
|
|
97
|
+
_getMetricSummary(): string;
|
|
98
|
+
_formatMetricParamValue(v: string | number): string;
|
|
99
|
+
/** Get version in different contexts
|
|
100
|
+
* In editor we use ScriptVersion->PublishScript instances
|
|
101
|
+
* In compute worker PublishScript
|
|
102
|
+
*/
|
|
103
|
+
_getVersion(): string;
|
|
104
|
+
/** Get version string like 'v1.0 at 10-20-2025 */
|
|
105
|
+
_getVersionSummary(): string;
|
|
106
|
+
_splitStringRecurse(strings: Array<string>, splitChars: Array<string>): Array<string>;
|
|
107
|
+
/** Create a block with one or more label and one or more texts
|
|
108
|
+
* The first label/text pair fills half of the container
|
|
109
|
+
* Used mostly for titleblock
|
|
110
|
+
*/
|
|
111
|
+
labelblock(labels: string | Array<string>, texts: string | Array<string>, options?: LabelBlockOptions): this;
|
|
112
|
+
/** Get last created ContainerBlock */
|
|
113
|
+
lastBlock(): ContainerBlock;
|
|
114
|
+
/** Set Page width or Container width based if View is active */
|
|
115
|
+
width(n: WidthHeightInput): Doc;
|
|
116
|
+
/** Set Page width or View width based if View is active */
|
|
117
|
+
height(n: WidthHeightInput): Doc;
|
|
118
|
+
/** Set Position of active Container
|
|
119
|
+
* @param x
|
|
120
|
+
* - if 0 <= x <= 1 relative to page content area 0.5 center)
|
|
121
|
+
* - if > 1 in default DocDocument units (mostly mm)
|
|
122
|
+
* - Alignment: topleft, bottom(center)
|
|
123
|
+
* - absolute with units ('10mm')
|
|
124
|
+
* - or array [x,y]
|
|
125
|
+
* @param y see x, but without array
|
|
126
|
+
*/
|
|
127
|
+
position(x: number | ContainerPositionLike, y?: number | string): Doc;
|
|
128
|
+
/** Set Pivot of active Container
|
|
129
|
+
* - relative to page content area (0.5,0.5 => center)
|
|
130
|
+
* - ContainerAlignment: 'left', 'top'
|
|
131
|
+
*
|
|
132
|
+
* NOTE: We won't allow offsets with units ('10mm')
|
|
133
|
+
*/
|
|
134
|
+
pivot(x: number | ContainerPositionLike | string | Array<number | number>, y?: number): Doc;
|
|
135
|
+
/** Turn on border on active container with optional styling */
|
|
136
|
+
border(style?: DocPathStyle): Doc;
|
|
137
|
+
/** set contentAlign on active container */
|
|
138
|
+
contentAlign(align: ContainerHAlignment | ContainerVAlignment | ContainerAlignment): Doc;
|
|
139
|
+
/** Set caption on active container */
|
|
140
|
+
caption(s?: string): this;
|
|
141
|
+
title(s?: string): this;
|
|
142
|
+
/** Bind ShapeCollection to View: either a real reference or the name of a ShapeCollection after running the doc pipeline */
|
|
143
|
+
shapes(shapes: AnyShapeOrCollection | string, all?: boolean): Doc;
|
|
144
|
+
zoom(level: number): Doc;
|
|
145
|
+
scale(factor?: ScaleInput): Doc;
|
|
146
|
+
/** Return names of docs present */
|
|
147
|
+
docs(): Array<string>;
|
|
148
|
+
getDoc(name: string): DocDocument | null;
|
|
149
|
+
getDocs(only?: Array<string> | any): Array<DocDocument>;
|
|
150
|
+
/** For moving Doc internally around from component scopes */
|
|
151
|
+
toInternalData(): Array<DocDocument>;
|
|
152
|
+
/** Export pure data */
|
|
153
|
+
toData(onlyDocs: string | Array<string>, noCache?: boolean): Promise<{
|
|
154
|
+
[key: string]: DocData;
|
|
155
|
+
} | undefined>;
|
|
156
|
+
/** Export selected or all DocDocuments to pdfs
|
|
157
|
+
* @param only string/Array of doc names to export. Default is all
|
|
158
|
+
* @returns Either single pdf ArrayBuffer or Record of ArrayBuffers if multiple docs are exported
|
|
159
|
+
*/
|
|
160
|
+
toPDF(only?: string | Array<string>): Promise<ArrayBuffer | Record<string, ArrayBuffer>>;
|
|
161
|
+
/** Convenience save documents in Doc module directly to PDF file */
|
|
162
|
+
save(filename?: string): Promise<void>;
|
|
163
|
+
_units(): DocUnits;
|
|
164
|
+
_generateContainerName(containerOrName: string | Container): string;
|
|
165
|
+
_checkPageIsActive(): boolean;
|
|
166
|
+
/** Transform WidthHeightInput to relative width/height */
|
|
167
|
+
_resolveWidthHeightInput(n: WidthHeightInput, page: Page, side: ContainerSide): [number, ContainerSizeRelativeTo];
|
|
168
|
+
/** Percentage of page space, page minus page-padding (not entire padding) */
|
|
169
|
+
_resolvePercentageString(s: PercentageString): number;
|
|
170
|
+
/** Return width or height in relative coords of current Page and DocDocument units */
|
|
171
|
+
_resolveValueWithUnitsStringToRel(s: ValueWithUnitsString, page: Page, side: PageSide): number;
|
|
172
|
+
/** Split given string like 10mm to number and unit and do some checking
|
|
173
|
+
* NOTE: We handle relative numbers ([0-1]) here too, in that case
|
|
174
|
+
*/
|
|
175
|
+
_splitInputNumberUnits(s: string | number): [number, DocUnitsWithPerc] | null;
|
|
176
|
+
parseInputNumberUnitsConvertTo(n: string | number, unit: DocUnitsWithPerc): number | null;
|
|
177
|
+
/** Merge incoming DocDocument instances with current document
|
|
178
|
+
* @d single or collection of DocDocument instance
|
|
179
|
+
*/
|
|
180
|
+
merge(d: DocDocument | Array<DocDocument> | Record<string, DocDocument>, namePrefix?: string): this;
|
|
181
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Doc, Page, DocUnits, PageSize, PageOrientation, DocPipeline, DocData } from './internal';
|
|
2
|
+
/** A document that is part of a Doc module instance
|
|
3
|
+
* It contains pages and some settings
|
|
4
|
+
*/
|
|
5
|
+
export declare class DocDocument {
|
|
6
|
+
DOC_DEFAULT_NAME: string;
|
|
7
|
+
DOC_UNITS_DEFAULT: DocUnits;
|
|
8
|
+
DOC_PAGE_SIZE_DEFAULT: PageSize;
|
|
9
|
+
DOC_PAGE_ORIENTATION_DEFAULT: PageOrientation;
|
|
10
|
+
name: string;
|
|
11
|
+
pageSize: PageSize;
|
|
12
|
+
pageOrientation: PageOrientation;
|
|
13
|
+
units: DocUnits;
|
|
14
|
+
_doc: Doc;
|
|
15
|
+
_pages: Array<Page>;
|
|
16
|
+
_pipelines: Array<DocPipeline>;
|
|
17
|
+
_activePage?: Page;
|
|
18
|
+
_component?: string;
|
|
19
|
+
constructor(doc: Doc, name: string);
|
|
20
|
+
/** Add page to this document */
|
|
21
|
+
createPage(name: string): Page;
|
|
22
|
+
pageExists(name: string): boolean;
|
|
23
|
+
addPipeline(p: DocPipeline): this;
|
|
24
|
+
toData(cache: Record<string, any> | undefined): Promise<DocData>;
|
|
25
|
+
/** Remove all references that tie this DocDocument instance to the execution scope */
|
|
26
|
+
resolveScopeReferences(): this;
|
|
27
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { PageSize, PageData, ContainerData, DocData, DocPathStyle } from './internal';
|
|
2
|
+
import { jsPDF } from 'jspdf';
|
|
3
|
+
export declare class DocPDFExporter {
|
|
4
|
+
DEBUG: boolean;
|
|
5
|
+
TEXT_ALIGN_DEFAULT: string;
|
|
6
|
+
TEXT_BASELINE_DEFAULT: string;
|
|
7
|
+
TEXT_FONT_DEFAULT: string;
|
|
8
|
+
TABLE_FONTSIZE_DEFAULT: number;
|
|
9
|
+
TABLE_BORDER_THICKNESS_MM: number;
|
|
10
|
+
TABLE_PADDING_MM: number;
|
|
11
|
+
_autoTableModule: any;
|
|
12
|
+
inDocs: Record<string, DocData>;
|
|
13
|
+
docs: Record<string, jsPDF>;
|
|
14
|
+
blobs: Record<string, Blob>;
|
|
15
|
+
activeDoc: DocData;
|
|
16
|
+
activePage: PageData;
|
|
17
|
+
activePDFDoc: jsPDF;
|
|
18
|
+
_jsPDF: any;
|
|
19
|
+
_jsPDFDoc: any;
|
|
20
|
+
_hasJsPDF: boolean;
|
|
21
|
+
_jsdomNode: any;
|
|
22
|
+
/** Make DocPDFExporter instance either empty or with data and onDone function */
|
|
23
|
+
constructor(data?: DocData | Record<string, DocData>, onDone?: (buffers: Record<string, ArrayBuffer>) => any);
|
|
24
|
+
reset(): void;
|
|
25
|
+
export(data: DocData | Record<string, DocData>): Promise<Record<string, ArrayBuffer>>;
|
|
26
|
+
/** Load jsPDF as module dynamically */
|
|
27
|
+
loadJsPDF(): Promise<DocPDFExporter>;
|
|
28
|
+
handleFailedImport(e: any): void;
|
|
29
|
+
handleSuccesImport(): void;
|
|
30
|
+
hasJsPDF(): boolean;
|
|
31
|
+
run(data: DocData | Record<string, DocData>): Promise<Record<string, Blob>>;
|
|
32
|
+
/** Parse raw Doc data, either DocData or a set of documents in Record<string, DocData> */
|
|
33
|
+
parse(data?: DocData | Record<string, DocData>): Promise<Record<string, Blob>>;
|
|
34
|
+
/** Make a simple PDF test document directly with jspdf */
|
|
35
|
+
generateTestDoc(): Promise<void>;
|
|
36
|
+
/** Save the given doc (or the first) to file */
|
|
37
|
+
_saveBlobToBrowserFile(docName?: string): Promise<void>;
|
|
38
|
+
/** Parse Doc data into PDFDocument */
|
|
39
|
+
_parseDoc(d: DocData): Promise<void>;
|
|
40
|
+
/** Set defaults of a JsPDF document */
|
|
41
|
+
setDocDefaults(d: jsPDF): void;
|
|
42
|
+
/** Wait until the active Doc stream is finished and place resulting Blob inside cache for later export */
|
|
43
|
+
_endActiveDoc(): Blob;
|
|
44
|
+
/** Get first Blob */
|
|
45
|
+
getBlob(): Blob | null;
|
|
46
|
+
_makePage(p: PageData): Promise<any>;
|
|
47
|
+
_placeContainer(c: ContainerData, p: PageData): Promise<void>;
|
|
48
|
+
/** Any elements for all Containers like border */
|
|
49
|
+
_placeContainerBasics(c: ContainerData, p: PageData): void;
|
|
50
|
+
/** Place text on activePDFDoc and active page */
|
|
51
|
+
_placeText(t: ContainerData, p: PageData): void;
|
|
52
|
+
/** Parse TextOptions to PDF text options, set basic styling directly on activePDFDoc and return parameters for specific creation function */
|
|
53
|
+
_setTextOptions(t: ContainerData, p: PageData): Record<string, any>;
|
|
54
|
+
/** First load the SVG or Bitmap image and then supply its buffer to jspdf */
|
|
55
|
+
_placeImage(img: ContainerData, p: PageData): Promise<void>;
|
|
56
|
+
/** Returns extension (without .) from url */
|
|
57
|
+
_getImageExt(url: string): string;
|
|
58
|
+
_getImageOptions(img: ContainerData, p: PageData): Record<string, any>;
|
|
59
|
+
/** Place View SVG on page
|
|
60
|
+
*
|
|
61
|
+
* - view.content.data contains raw SVG string (<svg _bbox="..." _worldUnits='mm'><path .. >... )
|
|
62
|
+
*
|
|
63
|
+
* - TODO:
|
|
64
|
+
* * Implement protection against making drawings bigger than page, resulting in weird pages etc
|
|
65
|
+
* * Implement view.zoomLevel, view.zoomRelativeTo etc. - NOW: only automatic filling of viewport/container
|
|
66
|
+
*
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
_placeViewSVG(view: ContainerData, p: PageData): void;
|
|
70
|
+
/** HACK: For some reason using this.activePDFDoc.path in _placeViewSVG()
|
|
71
|
+
* does not apply drawing and styling to canvas. By drawing this bogus empty rectangle it does!
|
|
72
|
+
* TODO: research why this works in code: https://github.com/parallax/jsPDF/blob/5d09af9135a2fe049c7d3c8b95df280d22e4a6db/src/jspdf.js#L4485
|
|
73
|
+
*/
|
|
74
|
+
_drawFakePath(): void;
|
|
75
|
+
/** Set PDF styling before drawing anything */
|
|
76
|
+
_setPathStyle(style?: DocPathStyle): jsPDF;
|
|
77
|
+
/** Place table using jsPDF AutoTable
|
|
78
|
+
* See: https://github.com/simonbengtsson/jsPDF-AutoTable
|
|
79
|
+
* NOTE: We use a dynamic import for developer flexibility. If you want to use it: install it.
|
|
80
|
+
*/
|
|
81
|
+
_placeTable(t: ContainerData, p: PageData): Promise<void>;
|
|
82
|
+
/** Place Graphic (hline, vline, rect, circle, etc) on active PDF page */
|
|
83
|
+
_placeGraphic(g: ContainerData, p: PageData): void;
|
|
84
|
+
isBrowser(): boolean;
|
|
85
|
+
isWorker(): boolean;
|
|
86
|
+
/** Convert relative page coordinate width to absolute PDF point coord of jsPDF system, also taking horizontal padding into account */
|
|
87
|
+
coordRelWidthToPoints(a: number, page: PageData, transformWithPadding?: boolean): number;
|
|
88
|
+
/** Convert relative page coordinate height to absolute PDF point coord of jsPDF system, also taking vertical padding into account */
|
|
89
|
+
coordRelHeightToPoints(a: number, page: PageData, transformWithPadding?: boolean): number;
|
|
90
|
+
/** Convert relative width (to page size or page-content) to points */
|
|
91
|
+
relWidthToPoints(a: number, page: PageData, withPadding?: boolean): number;
|
|
92
|
+
/** Convert relative height (to page size or page-content) to points */
|
|
93
|
+
relHeightToPoints(a: number, page: PageData, withPadding?: boolean): number;
|
|
94
|
+
pageHeightPoints(): number;
|
|
95
|
+
/** Convert Container position data to top left postion [x,y] in PDF points, including taking take of pivot position and Page.padding. In jspdf coord system
|
|
96
|
+
* NOTES:
|
|
97
|
+
* - All incoming ContainerData data (position, width, height) is relative to page size
|
|
98
|
+
*/
|
|
99
|
+
containerToPDFPositionInPnts(c: ContainerData, p: PageData): Record<string, number>;
|
|
100
|
+
removeEmptyValueKeysObj(obj: Object): {};
|
|
101
|
+
_getNewFileHandle(desc: any, mime: any, ext: any, open?: boolean): Promise<any>;
|
|
102
|
+
_writeFile(fileHandle: any, contents: any): Promise<void>;
|
|
103
|
+
pageSizeToLowercase(s: PageSize): string;
|
|
104
|
+
getSVGPreserveAspectRatioOption(view?: ContainerData): string;
|
|
105
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Doc, DocDocument, PageSide, WidthHeightInput, PageData, DocUnits, PageSize, PageOrientation, AnyPageContainer, ValueWithUnitsString } from './internal';
|
|
2
|
+
export declare class Page {
|
|
3
|
+
DEFAULT_PADDING: WidthHeightInput;
|
|
4
|
+
DEFAULT_SIZE: PageSize;
|
|
5
|
+
PAGE_ISO_SIZE_TO_WIDTH_HEIGHT_MM: {
|
|
6
|
+
A0: {
|
|
7
|
+
w: number;
|
|
8
|
+
h: number;
|
|
9
|
+
};
|
|
10
|
+
A1: {
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
};
|
|
14
|
+
A2: {
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
};
|
|
18
|
+
A3: {
|
|
19
|
+
w: number;
|
|
20
|
+
h: number;
|
|
21
|
+
};
|
|
22
|
+
A4: {
|
|
23
|
+
w: number;
|
|
24
|
+
h: number;
|
|
25
|
+
};
|
|
26
|
+
A5: {
|
|
27
|
+
w: number;
|
|
28
|
+
h: number;
|
|
29
|
+
};
|
|
30
|
+
A6: {
|
|
31
|
+
w: number;
|
|
32
|
+
h: number;
|
|
33
|
+
};
|
|
34
|
+
A7: {
|
|
35
|
+
w: number;
|
|
36
|
+
h: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
name: string;
|
|
40
|
+
_doc: Doc;
|
|
41
|
+
_DocDocument: DocDocument;
|
|
42
|
+
_units: DocUnits;
|
|
43
|
+
_size: PageSize;
|
|
44
|
+
_width: number;
|
|
45
|
+
_height: number;
|
|
46
|
+
_orientation: PageOrientation;
|
|
47
|
+
_padding: Array<number>;
|
|
48
|
+
_containers: Array<AnyPageContainer>;
|
|
49
|
+
_variables: {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
};
|
|
52
|
+
constructor(doc: Doc, DocDocumentName: DocDocument, name: string);
|
|
53
|
+
/** Inherit settings from DocDocument and Doc parents */
|
|
54
|
+
setDefaultsFromDoc(): void;
|
|
55
|
+
setDefaults(): void;
|
|
56
|
+
size(size: PageSize): void;
|
|
57
|
+
/** Set width of Page in DocDocument units */
|
|
58
|
+
width(n: WidthHeightInput): Page;
|
|
59
|
+
/** Set height of Page in DocDocument units */
|
|
60
|
+
height(n: WidthHeightInput): Page;
|
|
61
|
+
orientation(): Page;
|
|
62
|
+
/** Set padding width (left and right) and height (top and bottom)
|
|
63
|
+
* Use relative width/height ([0-1]), number with percentage (5%) or number with real units ('1cm','0.5"')
|
|
64
|
+
*/
|
|
65
|
+
padding(w: WidthHeightInput, h?: WidthHeightInput): Page;
|
|
66
|
+
/** Add AnyPageContainer to page */
|
|
67
|
+
add(container: AnyPageContainer): void;
|
|
68
|
+
/** Transform numeric value with units to relative position to page width or height */
|
|
69
|
+
_resolveValueWithUnitsStringToRel(s: ValueWithUnitsString, side: PageSide): number;
|
|
70
|
+
toData(cache?: Record<string, any> | undefined): Promise<PageData>;
|
|
71
|
+
resolveScopeReferences(): this;
|
|
72
|
+
_containerExists(name: string): boolean;
|
|
73
|
+
/** Transform given ISO page size (A0-A7) to units in DocDocument units */
|
|
74
|
+
_sizeToWidthHeight(size: PageSize): void;
|
|
75
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Page, WidthHeightInput, DocPathStyle, ContainerPositionRel, ContainerType, ContainerHAlignment, ContainerVAlignment, ContainerAlignment, ZoomRelativeTo, ScaleInput, ContainerSizeRelativeTo, ContainerPositionLike, ContainerData, Frame, ContainerPositionCoordAbs, ContainerPositionCoordRel, PageSide, ValueWithUnitsString } from './internal';
|
|
2
|
+
export declare class Container {
|
|
3
|
+
WIDTH_DEFAULT: number;
|
|
4
|
+
HEIGHT_DEFAULT: number;
|
|
5
|
+
PIVOT_DEFAULT: ContainerAlignment;
|
|
6
|
+
POSITION_DEFAULT: ContainerAlignment;
|
|
7
|
+
CONTENT_ALIGN_DEFAULT: ContainerAlignment;
|
|
8
|
+
name: string;
|
|
9
|
+
_page: Page;
|
|
10
|
+
_parent: Container;
|
|
11
|
+
_type: ContainerType;
|
|
12
|
+
_width: number;
|
|
13
|
+
_height: number;
|
|
14
|
+
_widthRelativeTo: ContainerSizeRelativeTo;
|
|
15
|
+
_heightRelativeTo: ContainerSizeRelativeTo;
|
|
16
|
+
_position: Array<number | number>;
|
|
17
|
+
_pivot: Array<number | number>;
|
|
18
|
+
_border: boolean;
|
|
19
|
+
_borderStyle: DocPathStyle;
|
|
20
|
+
_frame: Frame;
|
|
21
|
+
_index: number;
|
|
22
|
+
_contentAlign: ContainerAlignment;
|
|
23
|
+
_content: any;
|
|
24
|
+
_zoomLevel: ScaleInput;
|
|
25
|
+
_zoomRelativeTo: ZoomRelativeTo;
|
|
26
|
+
_title: string;
|
|
27
|
+
_caption: string;
|
|
28
|
+
constructor();
|
|
29
|
+
_setDefaults(): void;
|
|
30
|
+
/** Options set after container is placed on page */
|
|
31
|
+
_onPlaced(i?: any): any;
|
|
32
|
+
on(page: Page): Container;
|
|
33
|
+
checkOnPage(): void;
|
|
34
|
+
setName(n: string): this;
|
|
35
|
+
/** Set width of this Container. Either in percentage of page area ([0-1]) or or units like 10mm, 20pnt */
|
|
36
|
+
width(n: WidthHeightInput): void;
|
|
37
|
+
/** Set height of this Container. Either in percentage of page area ([0-1]) or or units like 10mm, 20pnt */
|
|
38
|
+
height(n: WidthHeightInput): void;
|
|
39
|
+
/** Set position with a ContainerAlignment or percentage of width and height [x,y] or absolute position with units */
|
|
40
|
+
position(p: ContainerPositionLike): Container;
|
|
41
|
+
_setPositionCoord(c: ContainerPositionCoordAbs | ContainerPositionCoordRel, side: PageSide): number;
|
|
42
|
+
/** Set pivot with a ContainerAlignment ('top', 'topright') or percentage of width and height [x,y] */
|
|
43
|
+
pivot(p: ContainerPositionLike): Container;
|
|
44
|
+
/** Set zoom level (which is relative to view container size) */
|
|
45
|
+
zoom(factor: number): void;
|
|
46
|
+
/** Set zoom level relative to world size of Shapes */
|
|
47
|
+
scale(factor: ScaleInput): void;
|
|
48
|
+
/** Turn on border on this container. Use without param to use default style */
|
|
49
|
+
border(style?: string | DocPathStyle): void;
|
|
50
|
+
caption(s: string): this;
|
|
51
|
+
title(s: string): this;
|
|
52
|
+
/** Transform from relative width (to page or page-content-area) to absolute (in DocUnits) */
|
|
53
|
+
_calculateAbsWidth(): number;
|
|
54
|
+
/** Transform from relative height (to page or page-content-area) to absolute (in DocUnits) */
|
|
55
|
+
_calculateAbsHeight(): number;
|
|
56
|
+
/** Alias for page._resolveValueWithUnitsStringToRel with active page (if any) */
|
|
57
|
+
_resolveValueWithUnitsStringToRel(s: ValueWithUnitsString, side: PageSide): number | null;
|
|
58
|
+
/** Export Data of Container */
|
|
59
|
+
toData(cache?: Record<string, any> | undefined): Promise<ContainerData>;
|
|
60
|
+
/** Output raw Container data */
|
|
61
|
+
_toContainerData(): ContainerData;
|
|
62
|
+
_containerHAlignmentToPositionRel(ax: ContainerHAlignment): number;
|
|
63
|
+
_containerVAlignmentToPositionRel(ay: ContainerVAlignment): number;
|
|
64
|
+
_containerAlignmentToPosition(a: ContainerAlignment): ContainerPositionRel;
|
|
65
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Container, ContainerData, DocUnits, DocGraphicType, DocGraphicInputBase, DocGraphicInputRect, DocGraphicInputCircle, DocGraphicInputLine } from './internal';
|
|
2
|
+
export declare class GraphicContainer extends Container {
|
|
3
|
+
DEFAULT_GRAPHIC_UNITS: DocUnits;
|
|
4
|
+
DEFAULT_GRAPHIC_PIVOT: number[];
|
|
5
|
+
_options: DocGraphicInputBase | DocGraphicInputRect | DocGraphicInputCircle | DocGraphicInputLine;
|
|
6
|
+
constructor(type: DocGraphicType, input: DocGraphicInputBase | DocGraphicInputRect | DocGraphicInputCircle | DocGraphicInputLine);
|
|
7
|
+
/** Set options and defaults */
|
|
8
|
+
setOptions(input: DocGraphicInputBase | DocGraphicInputRect | DocGraphicInputCircle | DocGraphicInputLine): void;
|
|
9
|
+
toData(): Promise<ContainerData>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Container, ContainerData, ContainerAlignment, ImageOptionsFit, ImageOptions } from './internal';
|
|
2
|
+
export declare class Image extends Container {
|
|
3
|
+
DEFAULT_FIT: ImageOptionsFit;
|
|
4
|
+
DEFAULT_ALIGN: ContainerAlignment;
|
|
5
|
+
DEFAULT_BRIGHTNESS: number;
|
|
6
|
+
DEFAULT_CONTRAST: number;
|
|
7
|
+
DEFAULT_SATURATION: number;
|
|
8
|
+
DEFAULT_GRAYSCALE: number;
|
|
9
|
+
_url: string;
|
|
10
|
+
_options: ImageOptions;
|
|
11
|
+
constructor(url: string, options: ImageOptions);
|
|
12
|
+
urlToName(url: string): string;
|
|
13
|
+
/** Set options and defaults */
|
|
14
|
+
setOptions(options: ImageOptions): void;
|
|
15
|
+
toData(cache?: Record<string, any> | undefined): Promise<ContainerData>;
|
|
16
|
+
/** We want to load the raw data of the image in the ContainerContent for easy access later (in HTML and PDF exporter) */
|
|
17
|
+
loadImageData(cache?: Record<string, any> | undefined): Promise<any>;
|
|
18
|
+
/** Export image data as DataUrl base64 string */
|
|
19
|
+
_exportImageDataBase64(data: ArrayBuffer): string;
|
|
20
|
+
getImageFormat(): 'jpg' | 'png' | 'svg';
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Container, ContainerData, DataRows, TableContainerOptions } from './internal';
|
|
2
|
+
export declare class TableContainer extends Container {
|
|
3
|
+
DEFAULT_FONT_SIZE: number;
|
|
4
|
+
DEFAULT_FONT_COLOR: string;
|
|
5
|
+
DEFAULT_TABLE_PIVOT_POSITION: number[];
|
|
6
|
+
DEFAULT_TABLE_POSITION: number[];
|
|
7
|
+
DEFAULT_TABLE_WIDTH: string;
|
|
8
|
+
DEFAULT_TABLE_HEIGHT: string;
|
|
9
|
+
_data: DataRows;
|
|
10
|
+
_options: TableContainerOptions;
|
|
11
|
+
constructor(data: DataRows, options: TableContainerOptions);
|
|
12
|
+
/** with Text Container width/height is less important than position and size - reflect this in setting to null by default */
|
|
13
|
+
_setDefaults(): void;
|
|
14
|
+
/** Set options and defaults */
|
|
15
|
+
setOptions(options?: TableContainerOptions): void;
|
|
16
|
+
/** Set size of text in traditional 'points'. Real doc units (mm,cm,inch) are converted to points */
|
|
17
|
+
_setFontSize(size: number | string): void;
|
|
18
|
+
/** Convert to Color hex with chroma */
|
|
19
|
+
_setFontColor(color: string): void;
|
|
20
|
+
toData(): Promise<ContainerData>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Container, ContainerData, TextOptions } from './internal';
|
|
2
|
+
export declare class Text extends Container {
|
|
3
|
+
DEFAULT_SIZE: string;
|
|
4
|
+
DEFAULT_COLOR: string;
|
|
5
|
+
DEFAULT_TEXT_PIVOT_POSITION: number[];
|
|
6
|
+
DEFAULT_TEXT_POSITION: number[];
|
|
7
|
+
FONT_SIZE_TO_HEIGHT_FACTOR: number;
|
|
8
|
+
_text: string;
|
|
9
|
+
_origOptions: TextOptions;
|
|
10
|
+
_options: TextOptions;
|
|
11
|
+
constructor(text: string, options: TextOptions);
|
|
12
|
+
/** with Text Container width/height is less important than position and size - reflect this in setting to null by default */
|
|
13
|
+
_setDefaults(): void;
|
|
14
|
+
/** Set options after added to page (overriden from parent class) */
|
|
15
|
+
_onPlaced(options?: TextOptions): void;
|
|
16
|
+
/** Set size of text in traditional 'points'. Real doc units (mm,cm,inch) are converted to points
|
|
17
|
+
* NOTE: a measure relative to page height does not work here!
|
|
18
|
+
*/
|
|
19
|
+
_setSize(size: number | string): void;
|
|
20
|
+
/** Convert to Color hex with chroma */
|
|
21
|
+
_setColor(color: string): void;
|
|
22
|
+
toData(): Promise<ContainerData>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Container, TextAreaAlign, TextAreaOptions } from './internal';
|
|
2
|
+
export declare class TextArea extends Container {
|
|
3
|
+
DEFAULT_SIZE: string;
|
|
4
|
+
DEFAULT_COLOR: string;
|
|
5
|
+
DEFAULT_ALIGN: TextAreaAlign;
|
|
6
|
+
DEFAULT_TEXTAREA_PIVOT_POSITION: number[];
|
|
7
|
+
DEFAULT_TEXTAREA_POSITION: number[];
|
|
8
|
+
DEFAULT_TEXTAREA_WIDTH: string;
|
|
9
|
+
DEFAULT_TEXTAREA_HEIGHT: string;
|
|
10
|
+
_text: string;
|
|
11
|
+
_options: TextAreaOptions;
|
|
12
|
+
constructor(text: string, options: TextAreaOptions);
|
|
13
|
+
_setDefaults(): void;
|
|
14
|
+
/** Set options and defaults */
|
|
15
|
+
setOptions(options?: TextAreaOptions): void;
|
|
16
|
+
/** Set size of text in traditional 'points'. Real doc units (mm,cm,inch) are converted to points */
|
|
17
|
+
_setSize(size: number | string): void;
|
|
18
|
+
/** Convert to Color hex with chroma */
|
|
19
|
+
_setColor(color: string): void;
|
|
20
|
+
/** Set alignment */
|
|
21
|
+
_setAlignment(align: TextAreaAlign): void;
|
|
22
|
+
toData(): Promise<any>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Container, ContainerData, AnyShapeOrCollection, ShapeCollection } from './internal';
|
|
2
|
+
export declare class View extends Container {
|
|
3
|
+
_shapes: ShapeCollection | string;
|
|
4
|
+
_resolvedShapesSVG: string;
|
|
5
|
+
_style: any;
|
|
6
|
+
_styles: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
_dimension: any;
|
|
10
|
+
_forceAll: boolean;
|
|
11
|
+
constructor();
|
|
12
|
+
toData(): Promise<ContainerData>;
|
|
13
|
+
/** For components we need to remove all references to Shapes */
|
|
14
|
+
resolveShapesToSVG(): string;
|
|
15
|
+
resolveShapeNameToSVG(shapesRef: string): string;
|
|
16
|
+
/** Bind ShapeCollection to View */
|
|
17
|
+
shapes(shapes: AnyShapeOrCollection | string, all?: boolean): void;
|
|
18
|
+
/** Used to remove DocDocument instances from execution scope
|
|
19
|
+
* Used in components
|
|
20
|
+
*/
|
|
21
|
+
resolveScopeReferences(): this;
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocUtils.ts
|
|
3
|
+
* Utility functions related to handling documents with Doc module
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare const POINTS_TO_DOC_UNITS: {
|
|
7
|
+
mm: number;
|
|
8
|
+
cm: number;
|
|
9
|
+
inch: number;
|
|
10
|
+
};
|
|
11
|
+
/** Convert value with units to font point size */
|
|
12
|
+
export declare function convertSizeUnitsToFontPoints(size: number | string): number;
|