Socket
Socket
Sign inDemoInstall

@shapediver/sdk.sdtf-v1

Package Overview
Dependencies
14
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.4.1

15

dist/binary_sdtf/ISdtfBinarySdtf.d.ts
import { ISdtfComponentList } from "../structure/ISdtfComponentList";
/** Handles parsing and construction of the three sdTF file parts: _Header_, _JSON content_ and _binary body_. */
export interface ISdtfBinarySdtf {
readonly binaryHeaderLength: number;
/** Constructs a new binary sdTF file from the given component list. */
constructBinarySdtf(componentList: ISdtfComponentList): ArrayBuffer;
/**
* Parses the given buffer data that holds a binary sdTF and returns its JSON content and body as buffers.
* @returns - [ JSON content buffer, binary body buffer ]
*/
parseBinarySdtf(sdtf: ArrayBuffer): [DataView, DataView];
/**
* Parses the given sdTF header and validates its parts.
* @returns - [ content length, total length ]
* @throws {@link SdtfError} when the validation fails.
*/
readHeader(header: DataView | ArrayBuffer): [number, number];
/**
* Encodes and parses the given sdTF JSON content buffer.
* @throws {@link SdtfError} when parsing of the content fails.
*/
readJsonContent(jsonContent: DataView | ArrayBuffer): Record<string, unknown>;
}
//# sourceMappingURL=ISdtfBinarySdtf.d.ts.map

3

dist/binary_sdtf/SdtfBinarySdtf.d.ts
import { ISdtfComponentList } from "../structure/ISdtfComponentList";
import { ISdtfBinarySdtf } from "./ISdtfBinarySdtf";
export declare class SdtfBinarySdtf implements ISdtfBinarySdtf {
/** Number of bytes of the sdTF header. */
readonly binaryHeaderLength = 20;

@@ -9,8 +8,6 @@ constructBinarySdtf(componentList: ISdtfComponentList): ArrayBuffer;

readHeader(header: DataView | ArrayBuffer): [number, number];
/** Creates an sdTF header buffer object. */
createHeader(contentLength: number, bodyLength: number): ArrayBuffer;
readJsonContent(jsonContent: DataView | ArrayBuffer): Record<string, unknown>;
/** Creates an sdTF JSON content buffer object. */
createJsonContent(componentList: ISdtfComponentList): ArrayBuffer;
}
//# sourceMappingURL=SdtfBinarySdtf.d.ts.map

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

constructor() {
/** Number of bytes of the sdTF header. */
this.binaryHeaderLength = 20;

@@ -17,3 +16,2 @@ }

const header = this.createHeader(jsonContent.byteLength, binaryBody.byteLength);
// Merge sdTF parts
return new Uint8Array([

@@ -51,7 +49,5 @@ ...new Uint8Array(header),

}
/** Creates an sdTF header buffer object. */
createHeader(contentLength, bodyLength) {
const buffer = new Uint8Array(20);
const headerDataView = new DataView(buffer.buffer, 0, buffer.byteLength);
// Write magic (here we must use Unicode encoding)
const magic = "sdtf";

@@ -62,12 +58,8 @@ headerDataView.setUint8(0, magic.codePointAt(0));

headerDataView.setUint8(3, magic.codePointAt(3));
// Write version
const version = 1;
headerDataView.setUint32(4, version, true);
// Write total length of file
const totalLength = this.binaryHeaderLength + contentLength + bodyLength;
headerDataView.setUint32(8, totalLength, true);
// Write length of content string
headerDataView.setUint32(12, contentLength, true);
// Write format string
const format = 0; // JSON
const format = 0;
headerDataView.setUint32(16, format, true);

@@ -86,3 +78,2 @@ return headerDataView.buffer;

}
/** Creates an sdTF JSON content buffer object. */
createJsonContent(componentList) {

@@ -89,0 +80,0 @@ const jsonContent = (0, ISdtfComponentList_1.toJsonContent)(componentList);

@@ -1,17 +0,5 @@

/**
* In-memory cache for sdTF buffer data.
* When a buffer was not found, it will be acquired and returned instead.
*/
export interface ISdtfBufferCache {
/** Stores the binary body of a binary sdTF in cache. */
setBinaryBody(binaryBody: DataView): void;
/**
* Returns the requested buffer from cache.
* When the buffer was not found in cache, the data is acquired and then put in cache for further use.
* @param rel - Buffer link relative to the sdTF JSON content.
* @param offset - Zero-based byte index at which to begin (inclusive).
* @param length - Length of the buffer.
*/
getBuffer(rel: string | undefined, offset: number, length: number): Promise<DataView>;
}
//# sourceMappingURL=ISdtfBufferCache.d.ts.map
import { ISdtfBufferCache } from "./ISdtfBufferCache";
export declare class SdtfBinaryBufferCache implements ISdtfBufferCache {
readonly cacheIdFullBuffer = "full";
/**
* Caching object used to store already fetched/loaded buffers.
* The key is a hash of the buffer's URI.
* The id encapsulates the offset and length of the buffer; or {@link cacheIdFullBuffer} for the entire buffer.
* @private
*/
readonly cache: {

@@ -16,32 +10,10 @@ [key: string]: {

constructor();
/**
* Calculates the cache key by hashing the given buffer URI.
* Simple, __insecure__ hashing function that's short, fast, and has no dependencies.
* @protected
*/
calcCacheKey(uri?: string): string;
/**
* Calculates the cache ID based on the given buffer range.
* @protected
*/
calcCacheId(offset: number, length: number): string;
/**
* Returns the buffer with the given key and range from cache.
* @protected
*/
loadFromCache(key: string, offset: number, length: number): DataView | undefined;
/**
* Stores the buffer with the given key and range in cache.
* @protected
*/
storeInCache(key: string, id: string, buffer: DataView): void;
setBinaryBody(binaryBody?: DataView): void;
getBuffer(uri: string | undefined, offset: number, length: number): Promise<DataView>;
/**
* Resolves and loads external buffer files - this is not supported in this mode!
* However, this can be overwritten by other buffer cache implementations.
* @protected
*/
acquireBuffer(uri: string | undefined, offset: number, length: number): Promise<DataView>;
}
//# sourceMappingURL=SdtfBinaryBufferCache.d.ts.map

@@ -19,7 +19,2 @@ "use strict";

}
/**
* Calculates the cache key by hashing the given buffer URI.
* Simple, __insecure__ hashing function that's short, fast, and has no dependencies.
* @protected
*/
calcCacheKey(uri = "") {

@@ -30,21 +25,12 @@ let hash = 0;

hash = (hash << 5) - hash + char;
hash &= hash; // Convert to 32bit integer
hash &= hash;
}
return new Uint32Array([hash])[0].toString(36);
}
/**
* Calculates the cache ID based on the given buffer range.
* @protected
*/
calcCacheId(offset, length) {
return `${offset};${length}`;
}
/**
* Returns the buffer with the given key and range from cache.
* @protected
*/
loadFromCache(key, offset, length) {
const item = this.cache[key];
if (!item) {
// Buffer not found in cache
return undefined;

@@ -54,16 +40,9 @@ }

if (item[id]) {
// Buffer found in cache for this range
return item[id];
}
if (item[this.cacheIdFullBuffer]) {
// Entire buffer object stored for this key - return range.
const buffer = item[this.cacheIdFullBuffer];
// However, the internally stored buffer might already contain a byte offset - take this into account!
return new DataView(buffer.buffer, buffer.byteOffset + offset, length);
}
}
/**
* Stores the buffer with the given key and range in cache.
* @protected
*/
storeInCache(key, id, buffer) {

@@ -89,7 +68,2 @@ var _a;

}
/**
* Resolves and loads external buffer files - this is not supported in this mode!
* However, this can be overwritten by other buffer cache implementations.
* @protected
*/
acquireBuffer(uri, offset, length) {

@@ -96,0 +70,0 @@ return __awaiter(this, void 0, void 0, function* () {

import { SdtfBinaryBufferCache } from "./SdtfBinaryBufferCache";
export declare class SdtfFileBufferCache extends SdtfBinaryBufferCache {
private readonly fileUtils;
/** The paths of all sdTF buffers of this sdTF asset are relative to the path of the JSON content file. */
private readonly basePath;
constructor(absolutePath: string);
/**
* Loads the requested buffer from disk and updates the internal buffer cache.
* @override
* @protected
*/
acquireBuffer(relativePath: string | undefined, offset: number, length: number): Promise<DataView>;
}
//# sourceMappingURL=SdtfFileBufferCache.d.ts.map

@@ -20,11 +20,5 @@ "use strict";

this.fileUtils = new SdtfFileUtils_1.SdtfFileUtils();
// Calculate the base path for all external buffers
const index = absolutePath.lastIndexOf("/");
this.basePath = absolutePath.substring(0, index);
}
/**
* Loads the requested buffer from disk and updates the internal buffer cache.
* @override
* @protected
*/
acquireBuffer(relativePath, offset, length) {

@@ -39,3 +33,2 @@ return __awaiter(this, void 0, void 0, function* () {

}
// Cache the entire buffer
this.storeInCache(this.calcCacheKey(relativePath), this.cacheIdFullBuffer, new DataView(buffer));

@@ -42,0 +35,0 @@ return new DataView(buffer, offset, length);

@@ -6,9 +6,4 @@ import { ISdtfHttpClient } from "../http/ISdtfHttpClient";

constructor(httpClient: ISdtfHttpClient);
/**
* Fetches the requested buffer and updates the internal buffer cache.
* @override
* @protected
*/
acquireBuffer(uri: string | undefined, offset: number, length: number): Promise<DataView>;
}
//# sourceMappingURL=SdtfHttpBufferCache.d.ts.map

@@ -19,11 +19,5 @@ "use strict";

}
/**
* Fetches the requested buffer and updates the internal buffer cache.
* @override
* @protected
*/
acquireBuffer(uri, offset, length) {
return __awaiter(this, void 0, void 0, function* () {
const [partialBuffer, entireBuffer] = yield this.httpClient.getBinaryBuffer(uri, offset, length);
// Cache the entire buffer if possible, otherwise the partial buffer
if (entireBuffer) {

@@ -30,0 +24,0 @@ this.storeInCache(this.calcCacheKey(uri), this.cacheIdFullBuffer, new DataView(entireBuffer));

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

if (command_jsonContent.options.url.includes(process.argv[3])) {
// Fetch and parse via url
const asset = yield sdk.createParser().readFromUrl(process.argv[4]);

@@ -62,3 +61,2 @@ console.log("sdTF JSON content:\n", sdk.createFormatter().prettifyReadableAsset(asset));

else if (command_jsonContent.options.file.includes(process.argv[3])) {
// Fetch and parse via file path
const asset = yield sdk.createParser().readFromFile(process.argv[4]);

@@ -68,3 +66,2 @@ console.log("sdTF JSON content:\n", sdk.createFormatter().prettifyReadableAsset(asset));

else if (process.argv[3] === undefined || general.help.includes(process.argv[3])) {
// help or undefined
printJsonContentCommandInfo();

@@ -71,0 +68,0 @@ }

import { ISdtfReadableAsset, ISdtfWriteableAsset } from "@shapediver/sdk.sdtf-core";
/** A simple beautifier that re-formats sdTF components. */
export interface ISdtfFormatter {
/** Prints the sdTF JSON content for the given readable asset. */
prettifyReadableAsset(asset: ISdtfReadableAsset): string;
/** Prints the sdTF JSON content for the given writeable asset. */
prettifyWriteableAsset(asset: ISdtfWriteableAsset): string;
}
//# sourceMappingURL=ISdtfFormatter.d.ts.map

@@ -10,8 +10,4 @@ import { ISdtfIntegration, ISdtfReadableAsset, ISdtfWriteableAsset } from "@shapediver/sdk.sdtf-core";

prettifyWriteableAsset(asset: ISdtfWriteableAsset): string;
/**
* Printify domain model.
* @private
*/
prettifyAsset(componentList: ISdtfComponentList): string;
}
//# sourceMappingURL=SdtfFormatter.d.ts.map

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

}
/**
* Printify domain model.
* @private
*/
prettifyAsset(componentList) {

@@ -29,0 +25,0 @@ const json = (0, ISdtfComponentList_1.toJsonContent)(componentList);

export interface ISdtfHttpClient {
/**
* Fetches the sdTF JSON content from the given URL.
*
* The client tries to minimize the amount of data sent by using HTTP range requests.
* However, whether this is supported depends on the server.
* If range requests are supported, only the `sdTF JSON content` is fetched and returned.
* Otherwise, the entire sdTF file is fetched.
* In this case, the `sdTF JSON content` is returned, as well as the `sdTF binary buffer`.
* @returns - [ sdTF JSON content, sdTF binary buffer ]
* @throws {@link SdtfError} when the request was not successful.
*/
getJsonContent(): Promise<[DataView, DataView | undefined]>;
/**
* Fetches the request part of the sdTF binary buffer.
* The given `uri` is relative to the JSON content of the sdTF file.
*
* The client tries to minimize the amount of data sent by using HTTP range requests.
* However, whether this is supported depends on the server.
* If range requests are supported, only the requested `part of the binary buffer` is fetched and returned.
* Otherwise, the entire sdTF binary buffer is fetched.
* In this case, the requested `part of the binary buffer` is returned, as well as the `entire binary buffer`.
* @param uri - URI relative to the sdTF JSON content.
* @param offset - Zero-based byte index at which to begin (inclusive).
* @param length - Length of the buffer.
* @returns - [ part of the binary buffer, entire binary buffer ]
* @throws {@link SdtfError} when the request was not successful.
*/
getBinaryBuffer(uri: string | undefined, offset: number, length: number): Promise<[DataView, ArrayBuffer | undefined]>;
}
//# sourceMappingURL=ISdtfHttpClient.d.ts.map
import { ISdtfHttpClient } from "./ISdtfHttpClient";
/** HTTP client of a single sdTF asset. */
export declare class SdtfHttpClient implements ISdtfHttpClient {
private readonly binarySdtfParser;
/** The URL of the sdTF JSON content. */
readonly jsonContentUrl: string;
/** the minimum headers object that should be used for all HTTP calls.. */
private readonly basicHttpHeader;
constructor(jsonContentUrl: string, authToken?: string);
/**
* Constructs the URL of this sdTF asset for the given URI.
* The URIs of all sdTF buffers of this sdTF asset are relative to the path of the JSON content file.
* When no URI is specified, the URL of the JSON content is returned.
* @private
*/
calcUrl(uri: string | undefined): string;
getJsonContent(): Promise<[DataView, DataView | undefined]>;
getBinaryBuffer(uri: string | undefined, offset: number, length: number): Promise<[DataView, ArrayBuffer | undefined]>;
/**
* Checks if the server supports HTTP range requests by sending a HEAD request and analyzing the response header.
* When the server supports range requests, only the requested part is fetched.
* Otherwise, the entire sdTF file is fetched.
* @private
* @param url
* @param offset - Zero-based byte index at which to begin (inclusive).
* @param length - Length of the buffer.
* @throws {@link SdtfError} when the request was not successful.
*/
fetch(url: string, offset: number, length: number): Promise<{

@@ -33,22 +14,5 @@ data: ArrayBuffer;

}>;
/**
* Sends an HTTP range request to fetch only the requested part.
* Assumes, that the server supports HTTP range requests and that the response is NOT compressed.
* Otherwise, Axios throws an `ERR_CONTENT_DECODING_FAILED` error in the browser.
* @private
* @param url
* @param offset - Zero-based byte index at which to begin (inclusive).
* @param length - Length of the buffer.
* @throws {@link SdtfError} when the request was not successful.
*/
fetchPartially(url: string, offset: number, length: number): Promise<any>;
/**
* Fetches the entire sdTF file (either a binary sdTF or just binary data).
* Fallback when HTTP range requests are not supported by the server.
* @private
* @param url
* @throws {@link SdtfError} when the request was not successful.
*/
fetchFully(url: string): Promise<any>;
}
//# sourceMappingURL=SdtfHttpClient.d.ts.map

@@ -19,9 +19,6 @@ "use strict";

const SdtfBinarySdtf_1 = require("../binary_sdtf/SdtfBinarySdtf");
/** HTTP client of a single sdTF asset. */
class SdtfHttpClient {
constructor(jsonContentUrl, authToken) {
this.binarySdtfParser = new SdtfBinarySdtf_1.SdtfBinarySdtf();
// This initializes this http client for the specified sdTF asset
this.jsonContentUrl = jsonContentUrl;
// Initialize tha basic HTTP header object
this.basicHttpHeader = {};

@@ -31,8 +28,2 @@ if (authToken)

}
/**
* Constructs the URL of this sdTF asset for the given URI.
* The URIs of all sdTF buffers of this sdTF asset are relative to the path of the JSON content file.
* When no URI is specified, the URL of the JSON content is returned.
* @private
*/
calcUrl(uri) {

@@ -49,3 +40,2 @@ if (!uri)

if (partial) {
// Partial requests are supported by the server - fetch json content next
const [contentLength, _] = this.binarySdtfParser.readHeader(data);

@@ -56,3 +46,2 @@ const jsonContentBuffer = yield this.fetch(this.jsonContentUrl, 20, contentLength);

else {
// Entire sdTF has been returned - parse and return
return this.binarySdtfParser.parseBinarySdtf(data);

@@ -71,7 +60,5 @@ }

if (partial) {
// Partial requests are supported by the server - partial buffer was fetched
return [new DataView(data), undefined];
}
else {
// Partial requests are supported by the server - entire buffer was fetched
return [new DataView(data, offset, length), data];

@@ -85,12 +72,2 @@ }

}
/**
* Checks if the server supports HTTP range requests by sending a HEAD request and analyzing the response header.
* When the server supports range requests, only the requested part is fetched.
* Otherwise, the entire sdTF file is fetched.
* @private
* @param url
* @param offset - Zero-based byte index at which to begin (inclusive).
* @param length - Length of the buffer.
* @throws {@link SdtfError} when the request was not successful.
*/
fetch(url, offset, length) {

@@ -106,17 +83,10 @@ var _a, _b;

}
// Validate response status
if (response.status > 299)
throw new sdk_sdtf_core_1.SdtfError(`Received HTTP status ${response.status}.`);
// Check if the content has been encoded (no range request possible)
const contentEncoding = !!((_a = response.headers["Content-Encoding"]) !== null && _a !== void 0 ? _a : response.headers["content-encoding"]);
// Check if HTTP range requests are supported
const acceptRanges = (_b = response.headers["Accept-Ranges"]) !== null && _b !== void 0 ? _b : response.headers["accept-ranges"];
// When the data has not been encoded and range requests are supported -> fetch partially.
// Otherwise -> fetch all.
const rangeRequestsSupported = (!contentEncoding && acceptRanges === "bytes");
// Fetch the actual data.
const data = (rangeRequestsSupported) ?
yield this.fetchPartially(url, offset, length) :
yield this.fetchFully(url);
// This is required to support Node.js as well as Browsers
const buffer = (data instanceof ArrayBuffer) ? data : Uint8Array.from(data).buffer;

@@ -129,12 +99,2 @@ return {

}
/**
* Sends an HTTP range request to fetch only the requested part.
* Assumes, that the server supports HTTP range requests and that the response is NOT compressed.
* Otherwise, Axios throws an `ERR_CONTENT_DECODING_FAILED` error in the browser.
* @private
* @param url
* @param offset - Zero-based byte index at which to begin (inclusive).
* @param length - Length of the buffer.
* @throws {@link SdtfError} when the request was not successful.
*/
fetchPartially(url, offset, length) {

@@ -152,3 +112,2 @@ return __awaiter(this, void 0, void 0, function* () {

}
// Validate response status
if (response.status === 416)

@@ -161,9 +120,2 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid range requested.");

}
/**
* Fetches the entire sdTF file (either a binary sdTF or just binary data).
* Fallback when HTTP range requests are not supported by the server.
* @private
* @param url
* @throws {@link SdtfError} when the request was not successful.
*/
fetchFully(url) {

@@ -173,3 +125,2 @@ return __awaiter(this, void 0, void 0, function* () {

try {
// NOTE: Axios automatically decodes the body (e.g. GZIP compression)
response = yield axios_1.default.get(url, {

@@ -183,3 +134,2 @@ headers: this.basicHttpHeader,

}
// Validate response status
if (response.status !== 200)

@@ -186,0 +136,0 @@ throw new sdk_sdtf_core_1.SdtfError(`Received HTTP status ${response.status}.`);

@@ -6,3 +6,2 @@ import { ISdtfReadableAccessor, ISdtfReadableAttribute, ISdtfReadableAttributes, ISdtfReadableContentComponent, ISdtfReadableTypeHint } from "@shapediver/sdk.sdtf-core";

entries: Record<string, ISdtfReadableAttribute>;
/** @override */
toDataObject(): Record<string, unknown>;

@@ -9,0 +8,0 @@ }

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

}
/** @override */
toDataObject() {

@@ -23,0 +22,0 @@ const dataObject = {};

@@ -10,3 +10,2 @@ import { ISdtfReadableBuffer } from "@shapediver/sdk.sdtf-core";

constructor(byteLength: number, bufferCache: ISdtfBufferCache);
/** @override */
toDataObject(): Record<string, unknown>;

@@ -13,0 +12,0 @@ getContent(offset: number, length: number): Promise<DataView>;

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

}
/** @override */
toDataObject() {

@@ -25,0 +24,0 @@ const dataObject = super.toDataObject();

@@ -12,3 +12,2 @@ import { ISdtfReadableAccessor, ISdtfReadableAttributes, ISdtfReadableContentComponent, ISdtfReadableDataItem, ISdtfReadableTypeHint } from "@shapediver/sdk.sdtf-core";

constructor(dataParser: ISdtfDataParser);
/** @override */
toDataObject(): Record<string, unknown>;

@@ -15,0 +14,0 @@ getContent(): Promise<unknown>;

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

}
/** @override */
toDataObject() {

@@ -23,0 +22,0 @@ const dataObject = super.toDataObject();

import { ISdtfReadableContentComponent } from "@shapediver/sdk.sdtf-core";
/**
* This is a wrapper around data access used in sdTF items and attributes.
* Data can either be stored directly in the JSON content (=value) or inside a buffer (=accessor).
* In general, data can be of any structure and therefore is of type `unknown`.
* However, data is usually coupled with a concrete type hints to make further processing easier.
* These type hints might impose a specific structural representation on the data.
* So data might be stored in a different structure than how they are used by the caller.
* For instance, a color might be represented by a string, but to improve usability, the color value is returned as an array.
*
* The `SdtfDataParser` class is responsible for parsing data and eventually mapping it into a specific structure
* depending on the data's concrete type hint.
*/
export interface ISdtfDataParser {
/** Parses the given data item with the registered readers. */
parseContent(component: ISdtfReadableContentComponent): Promise<unknown>;
}
//# sourceMappingURL=ISdtfDataParser.d.ts.map
import { ISdtfAccessor, ISdtfAttributes, ISdtfBuffer, ISdtfBufferView, ISdtfChunk, ISdtfDataItem, ISdtfFileInfo, ISdtfNode, ISdtfReadableAccessor, ISdtfReadableAttributes, ISdtfReadableBuffer, ISdtfReadableBufferView, ISdtfReadableChunk, ISdtfReadableDataItem, ISdtfReadableFileInfo, ISdtfReadableNode, ISdtfReadableTypeHint, ISdtfTypeHint } from "@shapediver/sdk.sdtf-core";
/**
* Creates instances of individual readable components.
* Replaces ID-references between components with object references.
*/
export interface ISdtfReadableComponentFactory {
/** Instantiates a new readable accessor object. */
createAccessor(accessor: ISdtfAccessor, bufferViews: ISdtfReadableBufferView[]): ISdtfReadableAccessor;
/** Instantiates a new readable attributes object. */
createAttributes(attribute: ISdtfAttributes, accessors: ISdtfReadableAccessor[], typeHints: ISdtfReadableTypeHint[]): ISdtfReadableAttributes;
/** Instantiates a new readable buffer object. */
createBuffer(buffer: ISdtfBuffer): ISdtfReadableBuffer;
/** Instantiates a new readable buffer view object. */
createBufferView(bufferView: ISdtfBufferView, buffers: ISdtfReadableBuffer[]): ISdtfReadableBufferView;
/** Instantiates a new readable chunk object. */
createChunk(chunk: ISdtfChunk, attributes: ISdtfReadableAttributes[], dataItems: ISdtfReadableDataItem[], typeHints: ISdtfReadableTypeHint[]): ISdtfReadableChunk;
/** Instantiates a new readable data item object. */
createDataItem(dataItem: ISdtfDataItem, accessors: ISdtfReadableAccessor[], attributes: ISdtfReadableAttributes[], typeHints: ISdtfReadableTypeHint[]): ISdtfReadableDataItem;
/** Instantiates a new readable file info object. */
createFileInfo(fileInfo: ISdtfFileInfo): ISdtfReadableFileInfo;
/**
* Instantiates a new readable node object.
*
* WARNING: Nodes referencing other nodes are not processed here!
*/
createNode(node: ISdtfNode, attributes: ISdtfReadableAttributes[], dataItems: ISdtfReadableDataItem[], typeHints: ISdtfReadableTypeHint[]): ISdtfReadableNode;
/** Instantiates a new readable type hint object. */
createTypeHint(typeHint: ISdtfTypeHint): ISdtfReadableTypeHint;
/** Links references from chunk to node components. */
setChunkReferences(readableChunks: ISdtfReadableChunk[], chunks: ISdtfChunk[], readableNodes: ISdtfReadableNode[]): void;
/** Links references between node components. */
setNodeReferences(readableNodes: ISdtfReadableNode[], nodes: ISdtfNode[]): void;
}
//# sourceMappingURL=ISdtfReadableComponentFactory.d.ts.map

@@ -19,10 +19,6 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
// Get the first integration that is supporting the given type hint
const integration = this.integrations.find(i => { var _a, _b; return i.isTypeHintSupported((_b = (_a = component.typeHint) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ""); });
// When an integration was found, all further steps are done by this integration (validation, mapping, etc)
if (integration) {
return integration.getReader().readComponent(component);
}
// Fallback behaviour, when no integration was found - return content.
// According to the sdTF specification, value precedes accessor!
if (component.value === undefined && !!component.accessor) {

@@ -29,0 +25,0 @@ return component.accessor.getContent();

@@ -15,10 +15,5 @@ import { ISdtfParser, ISdtfReadableAsset } from "@shapediver/sdk.sdtf-core";

readFromBuffer(sdtf: ArrayBuffer): ISdtfReadableAsset;
/** Instantiates a sdTF asset that represents the given content. */
createSdtfAsset(content: Record<string, unknown>, bufferCache: ISdtfBufferCache): ISdtfReadableAsset;
/**
* Transforms the given component list into a readable sdTF asset.
* @private
*/
buildReadableAsset(componentList: ISdtfComponentList, factory: ISdtfReadableComponentFactory): ISdtfReadableAsset;
}
//# sourceMappingURL=SdtfParser.d.ts.map

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

return __awaiter(this, void 0, void 0, function* () {
// Quick check to make sure we are in NodeJs
if (browser_or_node_1.isBrowser)

@@ -70,3 +69,2 @@ throw new sdk_sdtf_core_1.SdtfError("Reading from file is only supported in Node.js.");

}
/** Instantiates a sdTF asset that represents the given content. */
createSdtfAsset(content, bufferCache) {

@@ -77,6 +75,2 @@ const componentList = this.componentFactory.createFromJson(content);

}
/**
* Transforms the given component list into a readable sdTF asset.
* @private
*/
buildReadableAsset(componentList, factory) {

@@ -83,0 +77,0 @@ const fileInfo = factory.createFileInfo(componentList.fileInfo);

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

createAccessor(accessor, bufferViews) {
// Instantiate object
const readableAccessor = new SdtfReadableAccessor_1.SdtfReadableAccessor(bufferViews[accessor.bufferView]);

@@ -77,3 +76,2 @@ readableAccessor.bufferView = bufferViews[accessor.bufferView];

const readableNode = new SdtfReadableNode_1.SdtfReadableNode();
// NOTE the node property is ignored on purpose and later linked via `setNodeReferences`
if (node.attributes !== undefined)

@@ -80,0 +78,0 @@ readableNode.attributes = attributes[node.attributes];

import { ISdtfIntegration } from "@shapediver/sdk.sdtf-core";
/**
* Configuration options for an SDK instance.
* The user is can override every setting during creation of the SDK.
*/
export declare class SdtfConfig {
/**
* List of integrations that should be used after SDK was initialized.
*
* Default: [ {@link SdtfPrimitiveTypeIntegration}, {@link SdtfGeometryTypeIntegration} ].
*/
integrations: ISdtfIntegration[];
/**
* The JSON Web Token (JWT) to authorization HTTP calls.
*
* ShapeDiver models can be configured so that all interactions with them require a JSON Web Token (JWT) for
* authorization. In this case, a `401` HTTP status is returned when no `authToken` has been specified.
*/
authToken?: string;

@@ -20,0 +5,0 @@ constructor(config?: Partial<SdtfConfig>);

@@ -6,13 +6,4 @@ "use strict";

const sdk_sdtf_primitives_1 = require("@shapediver/sdk.sdtf-primitives");
/**
* Configuration options for an SDK instance.
* The user is can override every setting during creation of the SDK.
*/
class SdtfConfig {
constructor(config) {
/**
* List of integrations that should be used after SDK was initialized.
*
* Default: [ {@link SdtfPrimitiveTypeIntegration}, {@link SdtfGeometryTypeIntegration} ].
*/
this.integrations = [

@@ -19,0 +10,0 @@ new sdk_sdtf_primitives_1.SdtfPrimitiveTypeIntegration(),

@@ -5,5 +5,3 @@ import { ISdtfParser } from "@shapediver/sdk.sdtf-core";

import { ISdtfConstructor } from "./writer/ISdtfConstructor";
/** Partial definition of the sdk's config object. */
export type ISdtfConfig = Partial<SdtfConfig>;
/** Returns a new instance of the ShapeDiver sdTf SDK. */
export declare function create(config?: ISdtfConfig): Promise<SdtfSdk>;

@@ -13,18 +11,7 @@ export declare class SdtfSdk {

constructor(config?: ISdtfConfig);
/**
* Instantiates and returns a new sdTF parser object.
* The parser reads sdTF data from various sources and returns an asset object, that represents the hierarchy of
* the sdTF file and provides easy access functionality for embedded values and binary data.
*/
createParser(): ISdtfParser;
/**
* Instantiates and returns a new sdTF constructor object.
* The constructor provides functionality to create new sdTF assets.
*/
createConstructor(): ISdtfConstructor;
/** Instantiates and returns a new formatter to convert sdTF components into prettified JSON data. */
createFormatter(): ISdtfFormatter;
/** Initializes all specified sdTF integrations. */
init(): Promise<void>;
}
//# sourceMappingURL=SdtfSdk.d.ts.map

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

const SdtfConstructor_1 = require("./writer/SdtfConstructor");
/** Returns a new instance of the ShapeDiver sdTf SDK. */
function create(config) {

@@ -32,22 +31,11 @@ return __awaiter(this, void 0, void 0, function* () {

}
/**
* Instantiates and returns a new sdTF parser object.
* The parser reads sdTF data from various sources and returns an asset object, that represents the hierarchy of
* the sdTF file and provides easy access functionality for embedded values and binary data.
*/
createParser() {
return new SdtfParser_1.SdtfParser(this.config);
}
/**
* Instantiates and returns a new sdTF constructor object.
* The constructor provides functionality to create new sdTF assets.
*/
createConstructor() {
return new SdtfConstructor_1.SdtfConstructor(this.config.integrations);
}
/** Instantiates and returns a new formatter to convert sdTF components into prettified JSON data. */
createFormatter() {
return new SdtfFormatter_1.SdtfFormatter(this.config.integrations);
}
/** Initializes all specified sdTF integrations. */
init() {

@@ -54,0 +42,0 @@ return __awaiter(this, void 0, void 0, function* () {

import { ISdtfAccessor, ISdtfAsset, ISdtfAttributes, ISdtfBuffer, ISdtfBufferView, ISdtfChunk, ISdtfDataItem, ISdtfFileInfo, ISdtfNode, ISdtfTypeHint } from "@shapediver/sdk.sdtf-core";
/**
* Creates instances of individual sdTF components.
* The given data is analyzed for each component property and the respective data is only set when the TypeScript type
* matches; otherwise the property is left `unknown`.
* However, further validation must be executed later on to ensure correct values corresponding the sdTF specification.
*/
export interface ISdtfComponentFactory {

@@ -18,23 +12,13 @@ readonly propertyNameAccessors: string;

readonly propertyNameTypeHints: string;
/** Instantiates a new sdTF accessor object and sets the given data when the respective types are correct. */
createAccessor(accessorData: Record<string, unknown>): Partial<ISdtfAccessor>;
/** Instantiates a new sdTF asset object and sets the given data when the respective types are correct. */
createAsset(assetData: Record<string, unknown>): Partial<ISdtfAsset>;
/** Instantiates a new sdTF attributes object and sets the given data when the respective types are correct. */
createAttributes(attributesData: Record<string, unknown>): Partial<ISdtfAttributes>;
/** Instantiates a new sdTF buffer object and sets the given data when the respective types are correct. */
createBuffer(bufferData: Record<string, unknown>): Partial<ISdtfBuffer>;
/** Instantiates a new sdTF buffer view object and sets the given data when the respective types are correct. */
createBufferView(bufferViewData: Record<string, unknown>): Partial<ISdtfBufferView>;
/** Instantiates a new sdTF chunk object and sets the given data when the respective types are correct. */
createChunk(chunkData: Record<string, unknown>): Partial<ISdtfChunk>;
/** Instantiates a new sdTF data item object and sets the given data when the respective types are correct. */
createDataItem(dataItemData: Record<string, unknown>): Partial<ISdtfDataItem>;
/** Instantiates a new sdTF file info object and sets the given data when the respective types are correct. */
createFileInfo(fileInfoData: Record<string, unknown>): Partial<ISdtfFileInfo>;
/** Instantiates a new sdTF node object and sets the given data when the respective types are correct. */
createNode(nodeData: Record<string, unknown>): Partial<ISdtfNode>;
/** Instantiates a new sdTF type hint object and sets the given data when the respective types are correct. */
createTypeHint(typeHintData: Record<string, unknown>): Partial<ISdtfTypeHint>;
}
//# sourceMappingURL=ISdtfComponentFactory.d.ts.map
import { ISdtfReadableComponentList } from "../reader/ISdtfReadableComponentList";
import { ISdtfWriteableComponentList } from "../writer/ISdtfWriteableComponentList";
import { ISdtfComponentList } from "./ISdtfComponentList";
/** Wrapper around the component factory that encapsulates creational processes from different sources. */
export interface ISdtfComponentFactoryWrapper {
/** Create sdTF components from JSON data. */
createFromJson(json: Record<string, unknown>): ISdtfComponentList;
/** Create sdTF components from a readable asset representation. */
createFromReadable(readableComponents: ISdtfReadableComponentList): ISdtfComponentList;
/** Create sdTF components from a writable asset representation. */
createFromWriteable(writeableComponents: ISdtfWriteableComponentList): ISdtfComponentList;
}
//# sourceMappingURL=ISdtfComponentFactoryWrapper.d.ts.map
import { ISdtfAccessor, ISdtfAsset, ISdtfAttributes, ISdtfBuffer, ISdtfBufferView, ISdtfChunk, ISdtfDataItem, ISdtfFileInfo, ISdtfNode, ISdtfTypeHint } from "@shapediver/sdk.sdtf-core";
/** Holds all component instances that represent a single sdTF file. */
export interface ISdtfComponentList {

@@ -16,6 +15,2 @@ accessors: ISdtfAccessor[];

}
/**
* Holds all component instances that represent a single sdTF file.
* These components are partial representations and must be validated to ensure data correctness.
*/
export interface ISdtfPartialComponentList {

@@ -34,4 +29,3 @@ accessors: Partial<ISdtfAccessor>[];

}
/** Creates a sdTF JSON content object from the given component list. */
export declare function toJsonContent(componentList: ISdtfComponentList): Record<string, unknown>;
//# sourceMappingURL=ISdtfComponentList.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toJsonContent = void 0;
/** Creates a sdTF JSON content object from the given component list. */
function toJsonContent(componentList) {

@@ -6,0 +5,0 @@ const json = componentList.asset.toJson();

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

this.propertyNameFileInfo = "asset";
this.propertyNameFileInfoAlternative = "fileInfo"; // We might read from readable object as well
this.propertyNameFileInfoAlternative = "fileInfo";
this.propertyNameNodes = "nodes";

@@ -30,3 +30,2 @@ this.propertyNameTypeHints = "typeHints";

const accessor = new SdtfPartialAccessor_1.SdtfPartialAccessor();
// Set properties of allowed types
if ((0, sdk_sdtf_core_1.isNumber)(accessorData.bufferView))

@@ -36,3 +35,2 @@ accessor.bufferView = accessorData.bufferView;

accessor.id = accessorData.id;
// Add additional properties
Object

@@ -46,5 +44,3 @@ .entries(accessorData)

const asset = new SdtfPartialAsset_1.SdtfPartialAsset();
// There can only be one file info object
asset.fileInfo = 0;
// Add additional properties
Object

@@ -67,3 +63,2 @@ .entries(assetData)

const attributes = new SdtfPartialAttributes_1.SdtfPartialAttributes();
// Instantiate individual attributes and set properties
Object

@@ -75,3 +70,2 @@ .entries(attributesData)

const attribute = new SdtfPartialAttributes_1.SdtfAttribute();
// Set properties of allowed types
if (typeof data.accessor === "number")

@@ -88,3 +82,2 @@ attribute.accessor = data.accessor;

const buffer = new SdtfPartialBuffer_1.SdtfPartialBuffer();
// Set properties of allowed types
if ((0, sdk_sdtf_core_1.isNumber)(bufferData.byteLength))

@@ -94,3 +87,2 @@ buffer.byteLength = bufferData.byteLength;

buffer.uri = bufferData.uri;
// Add additional properties
Object

@@ -104,3 +96,2 @@ .entries(bufferData)

const bufferView = new SdtfPartialBufferView_1.SdtfPartialBufferView();
// Set properties of allowed types
if ((0, sdk_sdtf_core_1.isNumber)(bufferViewData.buffer))

@@ -118,3 +109,2 @@ bufferView.buffer = bufferViewData.buffer;

bufferView.name = bufferViewData.name;
// Add additional properties
Object

@@ -131,3 +121,2 @@ .entries(bufferViewData)

const dataItem = new SdtfPartialDataItem_1.SdtfPartialDataItem();
// Set properties of allowed types
if ((0, sdk_sdtf_core_1.isNumber)(dataItemData.accessor))

@@ -140,3 +129,2 @@ dataItem.accessor = dataItemData.accessor;

dataItem.value = dataItemData.value;
// Add additional properties
Object

@@ -150,3 +138,2 @@ .entries(dataItemData)

const fileInfo = new SdtfPartialFileInfo_1.SdtfPartialFileInfo();
// Set properties of allowed types
if (typeof fileInfoData.copyright === "string")

@@ -158,3 +145,2 @@ fileInfo.copyright = fileInfoData.copyright;

fileInfo.version = fileInfoData.version;
// Add additional properties
Object

@@ -168,3 +154,2 @@ .entries(fileInfoData)

const node = new SdtfPartialNode_1.SdtfPartialNode();
// Set properties of allowed types
if ((0, sdk_sdtf_core_1.isNumber)(nodeData.attributes))

@@ -180,3 +165,2 @@ node.attributes = nodeData.attributes;

node.typeHint = nodeData.typeHint;
// Add additional properties
Object

@@ -190,6 +174,4 @@ .entries(nodeData)

const typeHint = new SdtfPartialTypeHint_1.SdtfPartialTypeHint();
// Set properties of allowed types
if (typeof typeHintData.name === "string")
typeHint.name = typeHintData.name;
// Add additional properties
Object

@@ -196,0 +178,0 @@ .entries(typeHintData)

@@ -10,28 +10,7 @@ import { ISdtfReadableComponentList } from "../reader/ISdtfReadableComponentList";

createFromWriteable(writeableComponents: ISdtfWriteableComponentList): ISdtfComponentList;
/**
* Validates every partial-component and returns a corresponding component list.
* @private
* @throws {@link SdtfError} when a partial-component is invalid.
*/
createComponentList(partialComponents: ISdtfPartialComponentList): ISdtfComponentList;
/**
* Validation wrapper around the given create function for a content object of the specified name.
* @private
* @throws {@link SdtfError} when something goes wrong.
*/
buildFromObject<T>(jsonObject: Record<string, unknown>, propertyName: string, createFn: (data: Record<string, unknown>) => T): T;
/**
* Validation wrapper around the given create function for a content array of the specified name.
* @private
* @throws {@link SdtfError} when something goes wrong.
*/
buildFromArray<T>(jsonArray: Record<string, unknown>, propertyName: string, createFn: (data: Record<string, unknown>) => T): T[];
/**
* Readable and writeable components use object references to represent the hierarchy.
* However, sdTF components use reference IDs for this.
* This method maps the object representation into a reference ID representation.
* @private
*/
mapHierarchyRepresentation(target: ISdtfPartialComponentList, src: ISdtfWriteableComponentList | ISdtfReadableComponentList): void;
}
//# sourceMappingURL=SdtfComponentFactoryWrapper.d.ts.map

@@ -12,3 +12,3 @@ "use strict";

createFromJson(json) {
const f = this.factory; // Alias to shorten lines
const f = this.factory;
return this.createComponentList({

@@ -28,3 +28,3 @@ accessors: this.buildFromArray(json, f.propertyNameAccessors, f.createAccessor.bind(f)),

createFromReadable(readableComponents) {
const f = this.factory; // Alias to shorten lines
const f = this.factory;
const partialComponentList = {

@@ -47,3 +47,3 @@ accessors: readableComponents.accessors.map(a => f.createAccessor(a.toDataObject())),

var _a;
const f = this.factory; // Alias to shorten lines
const f = this.factory;
const partialComponentList = {

@@ -60,3 +60,2 @@ accessors: writeableComponents.accessors.map(a => f.createAccessor(a.toDataObject())),

typeHints: writeableComponents.typeHints.map(t => f.createTypeHint(t.toDataObject())),
// The writeable-optimizer merges all buffers, thus there is only a single binary buffer
binaryBody: (_a = writeableComponents.buffers.find(buffer => !buffer.uri)) === null || _a === void 0 ? void 0 : _a.data,

@@ -67,10 +66,4 @@ };

}
/**
* Validates every partial-component and returns a corresponding component list.
* @private
* @throws {@link SdtfError} when a partial-component is invalid.
*/
createComponentList(partialComponents) {
const validator = new SdtfComponentValidator_1.SdtfComponentValidator(partialComponents);
// NOTE the validation order is important here!
const asset = partialComponents.asset;

@@ -126,7 +119,2 @@ validator.validateAsset(asset);

}
/**
* Validation wrapper around the given create function for a content object of the specified name.
* @private
* @throws {@link SdtfError} when something goes wrong.
*/
buildFromObject(jsonObject, propertyName, createFn) {

@@ -138,7 +126,2 @@ const componentDataObject = (propertyName) ? jsonObject[propertyName] : jsonObject;

}
/**
* Validation wrapper around the given create function for a content array of the specified name.
* @private
* @throws {@link SdtfError} when something goes wrong.
*/
buildFromArray(jsonArray, propertyName, createFn) {

@@ -156,10 +139,3 @@ const componentDataArray = jsonArray[propertyName];

}
/**
* Readable and writeable components use object references to represent the hierarchy.
* However, sdTF components use reference IDs for this.
* This method maps the object representation into a reference ID representation.
* @private
*/
mapHierarchyRepresentation(target, src) {
// Helper to find the element position in an array
const getIndex = (list, componentId) => {

@@ -166,0 +142,0 @@ if (!componentId)

export declare class SdtfFileUtils {
/**
* Resolves the given relative path.
* @throws {@link SdtfError} when the path could not be resolved.
*/
toAbsolutePath(relativePath: string): string;
/**
* Reads the file asynchronously at the given path.
* @throws {@link SdtfError} when the file does not exist.
*/
readFile(absolutePath: string): Promise<ArrayBuffer>;
}
//# sourceMappingURL=SdtfFileUtils.d.ts.map

@@ -8,6 +8,2 @@ "use strict";

class SdtfFileUtils {
/**
* Resolves the given relative path.
* @throws {@link SdtfError} when the path could not be resolved.
*/
toAbsolutePath(relativePath) {

@@ -21,6 +17,2 @@ try {

}
/**
* Reads the file asynchronously at the given path.
* @throws {@link SdtfError} when the file does not exist.
*/
readFile(absolutePath) {

@@ -34,4 +26,2 @@ if (!fs.existsSync(absolutePath)) {

reject(error);
// The size of the buffer property is arbitrary.
// Thus, byte offset and length must be taken into account.
const data = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);

@@ -38,0 +28,0 @@ resolve(data);

@@ -1,5 +0,3 @@

/** Helper function to convert a readable or writable component into a basic JSON object that holds all relevant data. */
export declare function userComponentToDataObject(o: object): Record<string, unknown>;
/** Creates a random component id. */
export declare function createComponentId(): string;
//# sourceMappingURL=SdtfUtils.d.ts.map

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

const sdk_sdtf_core_1 = require("@shapediver/sdk.sdtf-core");
/** Helper function to convert a readable or writable component into a basic JSON object that holds all relevant data. */
function userComponentToDataObject(o) {

@@ -16,3 +15,2 @@ const additionalProperties = Object.keys(o).filter(prop => prop === "additionalProperties");

exports.userComponentToDataObject = userComponentToDataObject;
/** Creates a random component id. */
function createComponentId() {

@@ -19,0 +17,0 @@ return Math.random().toString(36).substring(2, 9);

import { ISdtfAccessor, ISdtfAsset, ISdtfAttributes, ISdtfBuffer, ISdtfBufferView, ISdtfChunk, ISdtfDataItem, ISdtfFileInfo, ISdtfNode, ISdtfTypeHint } from "@shapediver/sdk.sdtf-core";
/** Validates a partial component and ensures that its content corresponds to the sdTF v1 specification. */
export interface ISdtfComponentValidator {
/**
* Validates the partial accessor against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateAccessor(accessor: Partial<ISdtfAccessor>): asserts accessor is ISdtfAccessor;
/**
* Validates the partial accessor instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateAsset(asset: Partial<ISdtfAsset>): asserts asset is ISdtfAsset;
/**
* Validates the partial attributes instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateAttributes(attributes: Partial<ISdtfAttributes>): asserts attributes is ISdtfAttributes;
/**
* Validates the partial buffer instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateBuffer(buffer: Partial<ISdtfBuffer>): asserts buffer is ISdtfBuffer;
/**
* Validates the partial buffer view instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateBufferView(bufferView: Partial<ISdtfBufferView>): asserts bufferView is ISdtfBufferView;
/**
* Validates the partial chunk instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateChunk(chunk: Partial<ISdtfChunk>): asserts chunk is ISdtfChunk;
/**
* Validates the partial data-item instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateDataItem(dataItem: Partial<ISdtfDataItem>): asserts dataItem is ISdtfDataItem;
/**
* Validates the partial file-info instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateFileInfo(fileInfo: Partial<ISdtfFileInfo>): asserts fileInfo is ISdtfFileInfo;
/**
* Validates the partial node instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateNode(node: Partial<ISdtfNode>): asserts node is ISdtfNode;
/**
* Validates the partial type-hint instance against the sdTF v1 specification.
* @throws {@link SdtfError}
*/
validateTypeHint(typeHint: Partial<ISdtfTypeHint>): asserts typeHint is ISdtfTypeHint;
}
//# sourceMappingURL=ISdtfComponentValidator.d.ts.map

@@ -17,10 +17,4 @@ import { ISdtfAccessor, ISdtfAsset, ISdtfAttributes, ISdtfBuffer, ISdtfBufferView, ISdtfChunk, ISdtfDataItem, ISdtfFileInfo, ISdtfNode, ISdtfTypeHint } from "@shapediver/sdk.sdtf-core";

validateTypeHint(typeHint: Partial<ISdtfTypeHint>): asserts typeHint is ISdtfTypeHint;
/**
* Validates sdTF node objects.
* Thrown error messages have no prefix text to make them usable for chunk and nodes validation.
* @private
* @throws {@link SdtfError} when the component is invalid.
*/
validateChunkOrNode(chunkOrNode: Partial<ISdtfNode>): void;
}
//# sourceMappingURL=SdtfComponentValidator.d.ts.map

@@ -10,6 +10,4 @@ "use strict";

validateAccessor(accessor) {
// Validate required properties
if (!(0, sdk_sdtf_core_1.isUint)(accessor.bufferView))
throw new sdk_sdtf_core_1.SdtfError("Invalid accessor: Required property 'bufferView' must be an unsigned integer.");
// Validate component references
if (accessor.bufferView >= this.componentList.bufferViews.length)

@@ -19,7 +17,5 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid accessor: Buffer view index is out of range.");

validateAsset(asset) {
// Validate required properties
if (!(0, sdk_sdtf_core_1.isUint)(asset.fileInfo))
throw new sdk_sdtf_core_1.SdtfError("Invalid asset: Required property 'fileInfo' must be an unsigned integer.");
// Validate component references
if (asset.fileInfo !== 0) // There can only be one file info object
if (asset.fileInfo !== 0)
throw new sdk_sdtf_core_1.SdtfError("Invalid asset: Type hint index is out of range.");

@@ -32,9 +28,6 @@ }

.forEach((attribute) => {
// Validate required properties
if (!(0, sdk_sdtf_core_1.isUint)(attribute.typeHint))
throw new sdk_sdtf_core_1.SdtfError("Invalid attribute: Required property 'typeHint' must be an unsigned integer.");
// Validate optional properties
if (attribute.accessor && !(0, sdk_sdtf_core_1.isUint)(attribute.accessor))
throw new sdk_sdtf_core_1.SdtfError("Invalid attribute: Optional property 'accessor' must be an unsigned integer.");
// Validate component references
if (attribute.accessor && attribute.accessor >= this.componentList.accessors.length)

@@ -47,3 +40,2 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid attribute: Accessor index is out of range.");

validateBuffer(buffer) {
// Validate required properties
if (!(0, sdk_sdtf_core_1.isUint)(buffer.byteLength))

@@ -53,3 +45,2 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid buffer: Required property 'byteLength' must be an unsigned integer.");

validateBufferView(bufferView) {
// Validate required properties
if (!(0, sdk_sdtf_core_1.isUint)(bufferView.buffer))

@@ -63,3 +54,2 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid buffer view: Required property 'buffer' must be an unsigned integer.");

throw new sdk_sdtf_core_1.SdtfError("Invalid buffer view: Required property 'contentType' must be a non-empty string.");
// Validate component references
if (bufferView.buffer >= this.componentList.buffers.length)

@@ -75,3 +65,2 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid buffer view: Buffer index is out of range.");

}
// Validate required properties
if (typeof chunk.name !== "string")

@@ -81,6 +70,4 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid chunk: Required property 'name' must be a string.");

validateDataItem(dataItem) {
// Validate required properties
if (!(0, sdk_sdtf_core_1.isUint)(dataItem.typeHint))
throw new sdk_sdtf_core_1.SdtfError("Invalid item: Required property 'typeHint' must be an unsigned integer.");
// Validate optional properties
if (dataItem.accessor && !(0, sdk_sdtf_core_1.isUint)(dataItem.accessor))

@@ -90,3 +77,2 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid item: Optional property 'accessor' must be an unsigned integer.");

throw new sdk_sdtf_core_1.SdtfError("Invalid item: Optional property 'attributes' must be an unsigned integer.");
// Validate component references
if (dataItem.accessor && dataItem.accessor >= this.componentList.accessors.length)

@@ -100,3 +86,2 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid item: Accessor index is out of range.");

validateFileInfo(fileInfo) {
// Validate required properties
if (!(0, sdk_sdtf_core_1.isNonEmptyString)(fileInfo.version))

@@ -114,14 +99,6 @@ throw new sdk_sdtf_core_1.SdtfError("Invalid file info: Required property 'version' must be a non-empty string.");

validateTypeHint(typeHint) {
// Validate required properties
if (!(0, sdk_sdtf_core_1.isNonEmptyString)(typeHint.name))
throw new sdk_sdtf_core_1.SdtfError("Invalid type hint: Required property 'name' must be a non-empty string.");
}
/**
* Validates sdTF node objects.
* Thrown error messages have no prefix text to make them usable for chunk and nodes validation.
* @private
* @throws {@link SdtfError} when the component is invalid.
*/
validateChunkOrNode(chunkOrNode) {
// Validate optional properties
if (chunkOrNode.attributes && !(0, sdk_sdtf_core_1.isUint)(chunkOrNode.attributes))

@@ -135,3 +112,2 @@ throw new sdk_sdtf_core_1.SdtfError("Optional property 'attributes' must be an unsigned integer.");

throw new sdk_sdtf_core_1.SdtfError("Optional property 'typeHint' must be an unsigned integer.");
// Validate component references
if (chunkOrNode.attributes && chunkOrNode.attributes >= this.componentList.attributes.length)

@@ -149,3 +125,2 @@ throw new sdk_sdtf_core_1.SdtfError("Attributes index is out of range.");

throw new sdk_sdtf_core_1.SdtfError("Type hint index is out of range.");
// Prevent self-referencing nodes
if (!chunkOrNode.nodes.every(nodePos => this.componentList.nodes[nodePos].componentId !== chunkOrNode.componentId))

@@ -152,0 +127,0 @@ throw new sdk_sdtf_core_1.SdtfError("Node is referencing itself in the 'nodes' property.");

import { ISdtfWriteableAsset, ISdtfWriteableAttributes, ISdtfWriteableDataItem } from "@shapediver/sdk.sdtf-core";
/**
* Represents a data tree where each branch has a unique path.
*
* Representation of [GH_Structure](https://developer.rhino3d.com/api/grasshopper/html/T_Grasshopper_Kernel_Data_GH_Structure_1.htm).
*/
export interface ISdtfGrasshopperStructure {
/** List of all the data-arrays in this structure. */
branches: ISdtfWriteableDataItem[][];
/** List of all the paths in this structure. */
paths: number[][];
}
/**
* A builder to create a grasshopper sdTF asset.
* This sdTF asset includes chunks that are readable by the ShapeDiver Grasshopper input component.
*/
export interface ISdtfGrasshopperSdtfBuilder {
/**
* Adds a new chunk that holds grasshopper list data.
*
* Requirements:
* All data items must have the same type hint.
*/
addChunkForListData(parameterId: string, list: ISdtfWriteableDataItem[], chunkAttributes?: ISdtfWriteableAttributes): void;
/**
* Adds a new chunk that holds grasshopper tree data.
*
* Requirements:
* * All given data items must have the same type hint.
* * {@link tree.branches} and {@link tree.paths} must have the same number of elements (first level).
* * {@link tree.paths} must hold only integer numbers.
*/
addChunkForTreeData(parameterId: string, tree: ISdtfGrasshopperStructure, chunkAttributes?: ISdtfWriteableAttributes): void;

@@ -34,0 +9,0 @@ build(): ISdtfWriteableAsset;

@@ -16,30 +16,20 @@ "use strict";

this.asset.chunks.push(chunk);
// Add chunk attributes if given
if (chunkAttributes)
chunk.attributes = chunkAttributes;
// Validate grasshopper structure - `branches` and `paths` must have the same number of elements (first array level).
if (tree.branches.length !== tree.paths.length)
throw new sdk_sdtf_core_1.SdtfError("Invalid tree parameter: 'branches' and 'paths' of the grasshopper structure must have the same number of elements.");
// Validate grasshopper structure - The numbers in `paths` must all be integers.
if (!tree.paths.every(path => (0, sdk_sdtf_core_1.isIntArray)(path)))
throw new sdk_sdtf_core_1.SdtfError("Invalid tree parameter: 'paths' of the grasshopper structure must only consist of integer values.");
// Validate grasshopper structure - All data items must contain a type hint.
if (!tree.branches.every(branch => branch.every(item => { var _a; return !!((_a = item.typeHint) === null || _a === void 0 ? void 0 : _a.name); })))
throw new sdk_sdtf_core_1.SdtfError("Invalid tree parameter: All data items in 'tree.branches' must contain a type hint.");
let typeHint;
// Create nodes according to the given grasshopper tree structure
for (let i = 0; i < tree.branches.length; i++) {
const branch = tree.branches[i], path = tree.paths[i];
const node = this.factory.createNode();
// The numbers in path represent the name of the node
node.name = "[" + path.join(",") + "]";
// The branch holds all data of the node
branch.forEach(item => {
// The first data item sets the required type hint
if (!typeHint)
typeHint = item.typeHint.name;
// Validate grasshopper structure - All data items must have the same type hint.
if (typeHint !== item.typeHint.name)
throw new sdk_sdtf_core_1.SdtfError("Invalid tree parameter: All data items in 'tree.branches' must have the same type hint.");
// Add item to node
node.items.push(item);

@@ -46,0 +36,0 @@ });

@@ -5,3 +5,2 @@ import { ISdtfWriteableAccessor, ISdtfWriteableAttribute, ISdtfWriteableAttributes, ISdtfWriteableTypeHint } from "@shapediver/sdk.sdtf-core";

entries: Record<string, ISdtfWriteableAttribute>;
/** @override */
toDataObject(): Record<string, unknown>;

@@ -8,0 +7,0 @@ static clone(original: ISdtfWriteableAttributes): ISdtfWriteableAttributes;

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

}
/** @override */
toDataObject() {

@@ -16,0 +15,0 @@ return this.entries;

2

dist/writer/components/SdtfWriteableBuffer.js

@@ -13,3 +13,3 @@ "use strict";

clone.byteLength = orig.byteLength;
clone.data = orig.data; // NOTE shallow copy on purpose to reduce overall memory consumption!
clone.data = orig.data;
clone.uri = orig.uri;

@@ -16,0 +16,0 @@ clone.additionalProperties = Object.assign({}, orig.additionalProperties);

import { ISdtfWriteableAsset, ISdtfWriteableComponentFactory } from "@shapediver/sdk.sdtf-core";
import { ISdtfWriter } from "./ISdtfWriter";
export interface ISdtfConstructor {
/** Constructs a new binary sdTF file from the given asset. */
createBinarySdtf(asset: ISdtfWriteableAsset): ArrayBuffer;
/** Returns a low-level asset factory that allows to build complex sdTF structures. */
getFactory(): ISdtfWriteableComponentFactory;
/** Returns a high-level asset builder that allows to create simple sdTF structures directly from data. */
getWriter(): ISdtfWriter;
}
//# sourceMappingURL=ISdtfConstructor.d.ts.map

@@ -14,4 +14,3 @@ import { ISdtfWriteableAccessor, ISdtfWriteableAsset, ISdtfWriteableAttributes, ISdtfWriteableBuffer, ISdtfWriteableBufferView, ISdtfWriteableChunk, ISdtfWriteableDataItem, ISdtfWriteableFileInfo, ISdtfWriteableNode, ISdtfWriteableTypeHint } from "@shapediver/sdk.sdtf-core";

}
/** Extracts all referenced components from the writeable asset object and returns them as a component list. */
export declare function writeableComponentListFromAsset(asset: ISdtfWriteableAsset): ISdtfWriteableComponentList;
//# sourceMappingURL=ISdtfWriteableComponentList.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeableComponentListFromAsset = void 0;
/** Extracts all referenced components from the writeable asset object and returns them as a component list. */
function writeableComponentListFromAsset(asset) {
// Helper function to add components to list if they are not already in the list
const addToList = (component, array) => {

@@ -25,3 +23,2 @@ if (!component)

};
// NOTE: Extraction order matters!
list.chunks.forEach(chunk => {

@@ -28,0 +25,0 @@ addToList(chunk.attributes, list.attributes);

import { ISdtfWriteableAsset } from "@shapediver/sdk.sdtf-core";
import { ISdtfWriteableComponentList } from "./ISdtfWriteableComponentList";
/**
* Post-processor for a writable component list.
*
* The structure and handling of writeable components has been simplified to improve usability.
* However, these differences must be addressed before a writeable asset can be mapped to our domain model.
* This is done by the optimizer.
*/
export interface ISdtfWriteableComponentPostProcessor {
/** Calls component-writers of registered integrations, removes duplicated type hints and merges buffer data. */
optimize(asset: ISdtfWriteableAsset): ISdtfWriteableComponentList;
}
//# sourceMappingURL=ISdtfWriteableComponentPostProcessor.d.ts.map

@@ -19,15 +19,6 @@ import { ISdtfWriteableAsset, SdtfTypeHintName } from "@shapediver/sdk.sdtf-core";

}
/** A high-level asset builder that allows to create simple sdTF structures directly from data. */
export interface ISdtfWriter {
/**
* Creates a simple linear sdTF structure that consists of a single chunk with one or more data nodes.
* The given data content is either stored directly in the sdTF JSON content or in the sdTF buffer.
*/
createSimpleDataSdtf(chunkName: string, data: ISdtfWriterDataItem[]): ISdtfWriteableAsset;
/**
* Returns a new builder instance to create a grasshopper sdTF asset.
* This sdTF asset includes chunks that are readable by the ShapeDiver Grasshopper input component.
*/
createGrasshopperSdtfBuilder(): ISdtfGrasshopperSdtfBuilder;
}
//# sourceMappingURL=ISdtfWriter.d.ts.map

@@ -30,6 +30,2 @@ import { ISdtfWriteableAccessor, ISdtfWriteableAsset, ISdtfWriteableAttribute, ISdtfWriteableAttributes, ISdtfWriteableBuffer, ISdtfWriteableBufferView, ISdtfWriteableChunk, ISdtfWriteableComponentFactory, ISdtfWriteableDataItem, ISdtfWriteableNode, ISdtfWriteableTypeHint, SdtfTypeHintName } from "@shapediver/sdk.sdtf-core";

createTypeHint(name?: SdtfTypeHintName | string): ISdtfWriteableTypeHint;
/**
* Type guard for buffer content data.
* @private
*/
isBufferContent(content: unknown): content is {

@@ -36,0 +32,0 @@ data: ArrayBuffer;

@@ -86,6 +86,2 @@ "use strict";

}
/**
* Type guard for buffer content data.
* @private
*/
isBufferContent(content) {

@@ -92,0 +88,0 @@ return !!((0, sdk_sdtf_core_1.isDataObject)(content) && content.data && content.contentType);

@@ -9,54 +9,11 @@ import { ISdtfIntegration, ISdtfWriteableAsset, ISdtfWriteableAttribute, ISdtfWriteableBuffer, ISdtfWriteableDataItem, ISdtfWriteableTypeHint } from "@shapediver/sdk.sdtf-core";

optimize(asset: ISdtfWriteableAsset): ISdtfWriteableComponentList;
/**
* Tries to find a suitable registered integration for each given component and runs the integration's writer for
* each individual component.
* @private
*/
processDataComponents(components: (ISdtfWriteableAttribute | ISdtfWriteableDataItem)[]): void;
/**
* Tries to find a suitable registered integration for all given components and runs the integration's
* post-processor for all supported component (grouped).
* @private
*/
postProcessDataComponents(components: (ISdtfWriteableAttribute | ISdtfWriteableDataItem)[]): void;
/**
* Bottom-up approach to complement a missing type hint in node and chunk components.
* When all data items of a node are of a similar type hint, the respective type hint will be added to the node.
* When all nodes of a chunk are of a similar type hint, the respective type hint will be added to the chunk.
* @private
*/
complementTypeHints(componentList: ISdtfWriteableComponentList): void;
/**
* Generates a list of unique type hints for all components in the list and resets the component references accordingly.
* @private
*/
removeDuplicatedTypeHints(componentList: ISdtfWriteableComponentList): void;
/**
* Helper function to compare the two given type hints.
* Returns true, if both type hints have the same `name` property and share the same `additionalProperties`.
* However, the order of additional properties is not considered.
* @private
*/
areTypeHintsSimilar(t1: ISdtfWriteableTypeHint, t2: ISdtfWriteableTypeHint): boolean;
/**
* Merges all individual buffers by their URI.
* @private
*/
resolveBuffers(componentList: ISdtfWriteableComponentList): void;
/**
* Creates a new writeable buffer that holds the data of all given buffers.
* It returns the newly created buffer and a list of `byte offsets` corresponding to the given buffer.
* This allows to track down the individual buffers in the merged one.
* @private
* @returns - [ merged buffer, byte offset for each buffer ]
*/
mergeBuffers(uri: string, buffers: ISdtfWriteableBuffer[]): [ISdtfWriteableBuffer, number[]];
/**
* Creates a new writeable buffer that holds the data of all given buffers (hard copy!).
* It returns the newly created buffer and each buffer's `byte offset`.
* @private
* @returns - [ merged buffer, byte offset for each buffer ]
*/
mergeBufferData(buffers: ISdtfWriteableBuffer[]): [ArrayBuffer, number[]];
}
//# sourceMappingURL=SdtfWriteableComponentPostProcessor.d.ts.map

@@ -14,10 +14,6 @@ "use strict";

optimize(asset) {
// The optimization step will most likely change the given writeable objects.
// Without cloning, this function would consume the given asset and might make it's inner structure invalid.
const clonedAsset = SdtfWriteableAsset_1.SdtfWriteableAsset.clone(asset);
let componentList = (0, ISdtfWriteableComponentList_1.writeableComponentListFromAsset)(clonedAsset);
// Apply integration writers on data components
this.processDataComponents(componentList.attributes.flatMap(a => Object.values(a.entries)));
this.processDataComponents(componentList.items);
// Apply integration post-processor on data components
this.postProcessDataComponents([

@@ -27,4 +23,2 @@ ...componentList.attributes.flatMap(a => Object.values(a.entries)),

]);
// `processDataComponents` might create new components.
// Thus, we generate the component list again to include those new components as well.
componentList = (0, ISdtfWriteableComponentList_1.writeableComponentListFromAsset)(clonedAsset);

@@ -36,55 +30,28 @@ this.complementTypeHints(componentList);

}
/**
* Tries to find a suitable registered integration for each given component and runs the integration's writer for
* each individual component.
* @private
*/
processDataComponents(components) {
components.forEach(component => {
// Get the first integration that is supporting the given type hint
const integration = this.integrations.find(i => { var _a, _b; return i.isTypeHintSupported((_b = (_a = component.typeHint) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ""); });
// Stop when no integration was found for this type hint
if (!integration)
return;
// Post-process single component
integration.getWriter(this.factory).writeComponent(component);
});
}
/**
* Tries to find a suitable registered integration for all given components and runs the integration's
* post-processor for all supported component (grouped).
* @private
*/
postProcessDataComponents(components) {
this.integrations.forEach(integration => {
// Find all components that are supported by this integration
const supportedComponents = components.filter(component => { var _a, _b; return integration.isTypeHintSupported((_b = (_a = component.typeHint) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ""); });
// Stop when no components were found for this integration
if (supportedComponents.length === 0)
return;
// Post-process collective component
integration.getWriter(this.factory).postProcessComponents(supportedComponents);
});
}
/**
* Bottom-up approach to complement a missing type hint in node and chunk components.
* When all data items of a node are of a similar type hint, the respective type hint will be added to the node.
* When all nodes of a chunk are of a similar type hint, the respective type hint will be added to the chunk.
* @private
*/
complementTypeHints(componentList) {
// Helper function to complement
const complement = (base, list) => {
var _a, _b;
// Stop if the base has already a type hint with a name assigned
if (((_a = base.typeHint) === null || _a === void 0 ? void 0 : _a.name) !== undefined)
return;
// Stop if the list is empty
if (list.length === 0)
return;
let typeHintName = (_b = list[0].typeHint) === null || _b === void 0 ? void 0 : _b.name;
// Stop if the type hint is undefined
if (typeHintName === undefined)
return;
// Set type hint and update component list.
if (list.every(i => { var _a; return ((_a = i.typeHint) === null || _a === void 0 ? void 0 : _a.name) === typeHintName; })) {

@@ -95,14 +62,7 @@ base.typeHint = this.factory.createTypeHint(typeHintName);

};
// Check every node whether their respective data items are of similar a type hint
componentList.nodes.forEach(node => complement(node, node.items));
// Check every chunk whether their respective nodes are of similar a type hint
componentList.chunks.forEach(chunk => complement(chunk, chunk.nodes));
}
/**
* Generates a list of unique type hints for all components in the list and resets the component references accordingly.
* @private
*/
removeDuplicatedTypeHints(componentList) {
const uniqueTypeHints = [];
// Find all different type hint names
componentList.typeHints.forEach(typeHint => {

@@ -112,9 +72,6 @@ if (!uniqueTypeHints.find(this.areTypeHintsSimilar.bind(this, typeHint)))

});
// Replace the type hint of all components with the unique ones
const replaceTypeHints = (component) => {
// Stop if no type hint or type hint already in unique-list
if (!component.typeHint ||
uniqueTypeHints.find((typeHint) => typeHint.componentId === component.typeHint.componentId))
return;
// We know that there is a unique type hint for this component, so just search for it
component.typeHint = uniqueTypeHints.find((typeHint) => this.areTypeHintsSimilar(typeHint, component.typeHint));

@@ -126,11 +83,4 @@ };

componentList.nodes.forEach(n => replaceTypeHints(n));
// Update type hints in component list
componentList.typeHints = Object.values(uniqueTypeHints);
}
/**
* Helper function to compare the two given type hints.
* Returns true, if both type hints have the same `name` property and share the same `additionalProperties`.
* However, the order of additional properties is not considered.
* @private
*/
areTypeHintsSimilar(t1, t2) {

@@ -148,13 +98,6 @@ var _a, _b;

}
/**
* Merges all individual buffers by their URI.
* @private
*/
resolveBuffers(componentList) {
// List that sorts buffers/bufferViews by the buffer uri
const bufferViewsPerUri = {};
// Add buffer view to list
componentList.bufferViews.forEach(bufferView => {
var _a;
// We are not interested in buffer views that are not linked to a buffer
if (!bufferView.buffer)

@@ -167,7 +110,5 @@ return;

});
// We want to create a new buffer per uri that contains all buffer data of our list
const mergedBuffers = [];
Object.entries(bufferViewsPerUri).forEach(([uri, bufferViews]) => {
const [mergedBuffer, offsets] = this.mergeBuffers(uri, bufferViews.map(bv => bv.buffer));
// Update buffer information in buffer view
bufferViews.forEach((bufferView, i) => {

@@ -181,20 +122,9 @@ var _a;

});
// Update buffers in component list
componentList.buffers = mergedBuffers;
}
/**
* Creates a new writeable buffer that holds the data of all given buffers.
* It returns the newly created buffer and a list of `byte offsets` corresponding to the given buffer.
* This allows to track down the individual buffers in the merged one.
* @private
* @returns - [ merged buffer, byte offset for each buffer ]
*/
mergeBuffers(uri, buffers) {
const merged = new SdtfWriteableBuffer_1.SdtfWriteableBuffer();
merged.uri = uri;
// merged.additionalProperties = { ...buffers.map(b => b.additionalProperties ?? {}) } // Merge their additional properties
merged.additionalProperties = {};
// Merge additional properties
Object.assign(merged.additionalProperties, ...buffers.map(b => b.additionalProperties));
// Merge buffer data
const [mergedData, offsetsPerBuffer] = this.mergeBufferData(buffers);

@@ -205,14 +135,4 @@ merged.byteLength = mergedData.byteLength;

}
/**
* Creates a new writeable buffer that holds the data of all given buffers (hard copy!).
* It returns the newly created buffer and each buffer's `byte offset`.
* @private
* @returns - [ merged buffer, byte offset for each buffer ]
*/
mergeBufferData(buffers) {
var _a, _b;
/*
* According to the sdTF v1 specification, when concatenating two buffers, the size of the first buffer must be
* of a multiple of 4. This helper function rounds the given byte size up meet that criteria.
*/
const roundToNextMultipleOfFour = (value) => {

@@ -222,7 +142,4 @@ const diff = value % 4;

};
// The first buffer start at the beginning
let offsets = [0], lastBufferLength = (_b = (_a = buffers[0].data) === null || _a === void 0 ? void 0 : _a.byteLength) !== null && _b !== void 0 ? _b : 0;
// Calculate the offsets of each buffer
if (buffers.length > 0) {
// All buffers, except for the last one, must have a size that is a multiple of four
lastBufferLength = roundToNextMultipleOfFour(lastBufferLength);

@@ -233,3 +150,2 @@ for (let i = 1; i < buffers.length; i++) {

if (data) {
// All buffers, except for the last one, must have a size that is a multiple of four
if (i === buffers.length - 1)

@@ -244,5 +160,3 @@ bufferLength = data.byteLength;

}
// Create a new buffer and add the data of all the given buffers, according to the calculated offsets
const merged = new Uint8Array(offsets[offsets.length - 1] + lastBufferLength);
// Add content data to new buffer
buffers.forEach((buffer, i) => {

@@ -249,0 +163,0 @@ const data = (buffer.data) ? new Uint8Array(buffer.data) : new Uint8Array(0);

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

createSimpleDataSdtf(chunkName, data) {
// Helper to convert the format of attributes data
const mapAttributesData = (attr) => {

@@ -13,0 +12,0 @@ const res = {};

{
"name": "@shapediver/sdk.sdtf-v1",
"version": "1.4.0",
"version": "1.4.1",
"description": "Official sdTF SDK for TypeScript",

@@ -53,17 +53,17 @@ "keywords": [

"dependencies": {
"@shapediver/sdk.sdtf-core": "~1.4.0",
"@shapediver/sdk.sdtf-primitives": "~1.4.0",
"@shapediver/sdk.sdtf-geometry": "~1.4.0",
"axios": "~1.4.0",
"@shapediver/sdk.sdtf-core": "~1.4.1",
"@shapediver/sdk.sdtf-primitives": "~1.4.1",
"@shapediver/sdk.sdtf-geometry": "~1.4.1",
"axios": "~1.6.7",
"browser-or-node": "2.1.1"
},
"devDependencies": {
"jest": "~29.5.0",
"axios-mock-adapter": "~1.21.4",
"lerna": "~6.6.2",
"typescript": "~4.9.5",
"webpack": "~5.82.1",
"jest": "~29.7.0",
"axios-mock-adapter": "~1.22.0",
"lerna": "~7.4.2",
"typescript": "~5.3.3",
"webpack": "~5.90.1",
"webpack-cli": "~4.10.0",
"webpack-dev-server": "~4.15.0"
"webpack-dev-server": "~4.15.1"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc