New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@contrail/document-generation

Package Overview
Dependencies
Maintainers
9
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrail/document-generation - npm Package Compare versions

Comparing version 1.0.34 to 2.0.2

lib/board-document-generator.d.ts

1

lib/components/component-grid-generator.js

@@ -23,3 +23,2 @@ "use strict";

let dataIndex = 0;
console.log("generateComponentGrid: idealSize: ", idealSize);
let gridTemplate = template;

@@ -26,0 +25,0 @@ const optimizeTemplate = true;

@@ -1,11 +0,6 @@

import { DocumentElement, PositionDefinition } from "@contrail/documents";
import { DocumentGenerationOptions, DocumentTemplate } from "./interfaces";
import { DataGroup } from "@contrail/data-grouping";
import { DocumentElement } from "@contrail/documents";
import { DocumentGenerationOptions } from "./interfaces";
export declare class DocumentGenerator {
constructor();
static generateDocumentElements(options: DocumentGenerationOptions): Array<DocumentElement>;
static generateGroup(group: DataGroup, template: any, startingPosition: any, totalDepth: any, currentDepth: any): any[];
static getGroupSpan(group: DataGroup, totalDepth: any, currentDepth: any): number;
static generateFrameGroup(dataGroup: DataGroup, template: DocumentTemplate, position: PositionDefinition): Array<DocumentElement>;
static generateGroupHeading(dataGroup: DataGroup, template: DocumentTemplate, position: PositionDefinition, span: any): any[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentGenerator = void 0;
const documents_1 = require("@contrail/documents");
const interfaces_1 = require("./interfaces");
const util_1 = require("@contrail/util");
const frame_generator_1 = require("./frame-generator");
const document_util_1 = require("./util/document-util");
const board_document_generator_1 = require("./board-document-generator");
class DocumentGenerator {

@@ -13,96 +9,5 @@ constructor() {

static generateDocumentElements(options) {
const elements = [];
const structure = options.data.dataGroup;
const template = options.documentTemplateDefinition;
console.log("generateDocumentElements: ", structure.depth, structure.groupingProperties.length);
let position = options.startingCoordinates || { x: 0, y: 0 };
const group = structure.rootGroup;
elements.push(...this.generateGroup(group, template, position, structure.depth, 0));
return elements;
return board_document_generator_1.BoardDocumentGenerator.generateDocumentElements(options);
}
static generateGroup(group, template, startingPosition, totalDepth, currentDepth) {
const elements = [];
let position = util_1.ObjectUtil.cloneDeep(startingPosition);
if (currentDepth > 0) {
let groupHeaderPosition = { x: position.x + template.framePadding, y: position.y + template.framePadding };
let span = this.getGroupSpan(group, totalDepth, currentDepth);
elements.push(...this.generateGroupHeading(group, template, groupHeaderPosition, span));
let groupHeaderDimensions = { width: template.frameSize.width, height: template.frameGroupHeaderTemplate.size.height };
if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
position = { x: position.x + groupHeaderDimensions.height + template.framePadding, y: position.y };
}
else {
position = { x: position.x, y: position.y + groupHeaderDimensions.height + template.framePadding };
}
}
if (currentDepth === totalDepth) {
elements.push(...this.generateFrameGroup(group, template, position));
}
if (currentDepth < totalDepth) {
for (let subGroup of group.subGroups) {
elements.push(...this.generateGroup(subGroup, template, position, totalDepth, currentDepth + 1));
let frameSetMultiple = this.getGroupSpan(subGroup, totalDepth, currentDepth + 1);
let paddingMultiple = 1;
if (currentDepth < totalDepth) {
paddingMultiple = frameSetMultiple;
}
if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
position = { x: position.x, y: position.y + (template.frameSize.height * frameSetMultiple) + (template.framePadding * paddingMultiple) };
}
else {
position = { x: position.x + (template.frameSize.width * frameSetMultiple) + (template.framePadding * paddingMultiple), y: position.y };
}
}
}
return elements;
}
static getGroupSpan(group, totalDepth, currentDepth) {
let span = 1;
if (currentDepth !== totalDepth) {
span = group.subGroups.length;
}
return span;
}
static generateFrameGroup(dataGroup, template, position) {
const elements = [];
let framePosition = { x: position.x + template.framePadding, y: position.y + template.framePadding };
for (let group of dataGroup.subGroups) {
elements.push(...frame_generator_1.FrameGenerator.generateFrameForDataGroup(group, framePosition, template));
if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
framePosition.x = framePosition.x + template.frameSize.width + template.framePadding || 10;
}
else {
framePosition.y = framePosition.y + template.frameSize.height + template.framePadding || 10;
}
}
return elements;
}
static generateGroupHeading(dataGroup, template, position, span) {
const elements = [];
const heading = documents_1.DocumentElementFactory.createTextElement("Placeholder", {});
heading.style = { border: { width: 1, color: "rgba(0,0,0,0)" }, color: "#000000", backgroundColor: template.frameGroupHeaderTemplate.style.backgroundColor || 'black' };
heading.text = `<p><span style=\"font-size: ${template.frameGroupHeaderTemplate.style.font.size}pt;\"><strong><span style=\"color: ${template.frameGroupHeaderTemplate.style.color};\">${document_util_1.DocumentUtil.sanitizeHTML(dataGroup.name)}</span></strong></span></p>`;
heading.position = position;
if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
let sizeDim = template.frameSize.height * span;
if (span > 1) {
sizeDim += (span - 1) * template.framePadding;
}
heading.size = { width: sizeDim, height: template.frameGroupHeaderTemplate.size.height };
heading.rotate = { angle: 270 };
heading.position.x = heading.position.x - (heading.size.width / 2) + (heading.size.height / 2);
heading.position.y = heading.position.y + (heading.size.width / 2) - (heading.size.height / 2);
}
else {
let sizeDim = template.frameSize.width * span;
if (span > 1) {
sizeDim += (span - 1) * template.framePadding;
}
heading.rotate = { angle: 0 };
heading.size = { width: sizeDim, height: template.frameGroupHeaderTemplate.size.height };
}
elements.push(heading);
return elements;
}
}
exports.DocumentGenerator = DocumentGenerator;
{
"name": "@contrail/document-generation",
"version": "1.0.34",
"version": "2.0.2",
"description": "Utilities for automatic generation of documents.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc