@@ -156197,84 +156197,84 @@ jsPDF.API.PDFObject = (function() {
156197156197 */
156198156198
156199156199
156200- /******************************************************************************
156201- Copyright (c) Microsoft Corporation.
156202- 
156203- Permission to use, copy, modify, and/or distribute this software for any
156204- purpose with or without fee is hereby granted.
156205- 
156206- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
156207- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
156208- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
156209- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
156210- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
156211- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
156212- PERFORMANCE OF THIS SOFTWARE.
156213- ***************************************************************************** */
156214- /* global Reflect, Promise */
156215- 
156216- var extendStatics = function(d, b) {
156217-     extendStatics = Object.setPrototypeOf ||
156218-         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
156219-         function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
156220-     return extendStatics(d, b);
156221- };
156222- 
156223- function __extends(d, b) {
156224-     if (typeof b !== "function" && b !== null)
156225-         throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
156226-     extendStatics(d, b);
156227-     function __() { this.constructor = d; }
156228-     d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
156229- }
156230- 
156231- var __assign = function() {
156232-     __assign = Object.assign || function __assign(t) {
156233-         for (var s, i = 1, n = arguments.length; i < n; i++) {
156234-             s = arguments[i];
156235-             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
156236-         }
156237-         return t;
156238-     };
156239-     return __assign.apply(this, arguments);
156240- };
156241- 
156242- function __awaiter(thisArg, _arguments, P, generator) {
156243-     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
156244-     return new (P || (P = Promise))(function (resolve, reject) {
156245-         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
156246-         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
156247-         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
156248-         step((generator = generator.apply(thisArg, _arguments || [])).next());
156249-     });
156250- }
156251- 
156252- function __generator(thisArg, body) {
156253-     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
156254-     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
156255-     function verb(n) { return function (v) { return step([n, v]); }; }
156256-     function step(op) {
156257-         if (f) throw new TypeError("Generator is already executing.");
156258-         while (_) try {
156259-             if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
156260-             if (y = 0, t) op = [op[0] & 2, t.value];
156261-             switch (op[0]) {
156262-                 case 0: case 1: t = op; break;
156263-                 case 4: _.label++; return { value: op[1], done: false };
156264-                 case 5: _.label++; y = op[1]; op = [0]; continue;
156265-                 case 7: op = _.ops.pop(); _.trys.pop(); continue;
156266-                 default:
156267-                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
156268-                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
156269-                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
156270-                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
156271-                     if (t[2]) _.ops.pop();
156272-                     _.trys.pop(); continue;
156273-             }
156274-             op = body.call(thisArg, _);
156275-         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
156276-         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
156277-     }
156200+ /******************************************************************************
156201+ Copyright (c) Microsoft Corporation.
156202+ 
156203+ Permission to use, copy, modify, and/or distribute this software for any
156204+ purpose with or without fee is hereby granted.
156205+ 
156206+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
156207+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
156208+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
156209+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
156210+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
156211+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
156212+ PERFORMANCE OF THIS SOFTWARE.
156213+ ***************************************************************************** */
156214+ /* global Reflect, Promise */
156215+ 
156216+ var extendStatics = function(d, b) {
156217+     extendStatics = Object.setPrototypeOf ||
156218+         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
156219+         function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
156220+     return extendStatics(d, b);
156221+ };
156222+ 
156223+ function __extends(d, b) {
156224+     if (typeof b !== "function" && b !== null)
156225+         throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
156226+     extendStatics(d, b);
156227+     function __() { this.constructor = d; }
156228+     d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
156229+ }
156230+ 
156231+ var __assign = function() {
156232+     __assign = Object.assign || function __assign(t) {
156233+         for (var s, i = 1, n = arguments.length; i < n; i++) {
156234+             s = arguments[i];
156235+             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
156236+         }
156237+         return t;
156238+     };
156239+     return __assign.apply(this, arguments);
156240+ };
156241+ 
156242+ function __awaiter(thisArg, _arguments, P, generator) {
156243+     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
156244+     return new (P || (P = Promise))(function (resolve, reject) {
156245+         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
156246+         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
156247+         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
156248+         step((generator = generator.apply(thisArg, _arguments || [])).next());
156249+     });
156250+ }
156251+ 
156252+ function __generator(thisArg, body) {
156253+     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
156254+     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
156255+     function verb(n) { return function (v) { return step([n, v]); }; }
156256+     function step(op) {
156257+         if (f) throw new TypeError("Generator is already executing.");
156258+         while (_) try {
156259+             if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
156260+             if (y = 0, t) op = [op[0] & 2, t.value];
156261+             switch (op[0]) {
156262+                 case 0: case 1: t = op; break;
156263+                 case 4: _.label++; return { value: op[1], done: false };
156264+                 case 5: _.label++; y = op[1]; op = [0]; continue;
156265+                 case 7: op = _.ops.pop(); _.trys.pop(); continue;
156266+                 default:
156267+                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
156268+                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
156269+                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
156270+                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
156271+                     if (t[2]) _.ops.pop();
156272+                     _.trys.pop(); continue;
156273+             }
156274+             op = body.call(thisArg, _);
156275+         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
156276+         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
156277+     }
156278156278}
156279156279
156280156280/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types */
@@ -158586,7 +158586,7 @@ var GeometryNode = /** @class */ (function (_super) {
158586158586                if (prev instanceof MoveTo || prev instanceof LineTo || prev instanceof CurveTo) {
158587158587                    if (curr instanceof CurveTo) {
158588158588                        hasStartMarker &&
158589-                             markers.addMarker(new Marker(markerStart, [prev.x, prev.y],  
158589+                             markers.addMarker(new Marker(markerStart, [prev.x, prev.y],
158590158590                            // @ts-ignore
158591158591                            getAngle(last_1 ? [last_1.x, last_1.y] : [prev.x, prev.y], [curr.x1, curr.y1]), true));
158592158592                        hasEndMarker &&
@@ -159304,7 +159304,7 @@ var TextNode = /** @class */ (function (_super) {
159304159304                    textChunks = [];
159305159305                    currentTextSegment = new TextChunk(this, context.attributeState.textAnchor, textX + dx, textY + dy);
159306159306                    textChunks.push({ type: '', chunk: currentTextSegment });
159307-                     initialSpace = this.processTSpans(this, this.element, context, textChunks, currentTextSegment,  
159307+                     initialSpace = this.processTSpans(this, this.element, context, textChunks, currentTextSegment,
159308159308                    // Set prevText to ' ' so any spaces on left of <text> are trimmed
159309159309                    { prevText: ' ', prevContext: context });
159310159310                    lengthAdjustment = initialSpace ? 0 : 1;
@@ -161586,7 +161586,7 @@ var Anchor = /** @class */ (function (_super) {
161586161586                            box = this.getBoundingBox(context);
161587161587                            scale = context.pdf.internal.scaleFactor;
161588161588                            ph = context.pdf.internal.pageSize.getHeight();
161589-                             context.pdf.link(scale * (box[0] * context.transform.sx + context.transform.tx), ph -  scale * (box[1] * context.transform.sy +  context.transform.ty), scale * box[2], scale * box[3], { url: href });
161589+                             context.pdf.link(scale * (box[0] * context.transform.sx + context.transform.tx), scale * (ph -  box[1] * context.transform.sy -  context.transform.ty), scale * context.transform.sx *  box[2], scale * context.transform.sy  * box[3], { url: href });
161590161590                        }
161591161591                        return [2 /*return*/];
161592161592                }
@@ -175277,8 +175277,14 @@ class RBufferReader {
175277175277
175278175278  // Move to a specific position in the buffer
175279175279  seek(position) {
175280+   if (typeof position === 'bigint') {
175281+     if (position > BigInt(Number.MAX_SAFE_INTEGER))
175282+       throw new Error(`Offset too large to seek safely: ${position}`);
175283+     this.offset = Number(position); 
175284+   } else 
175280175285    this.offset = position;
175281-   }
175286+ }
175287+ 
175282175288
175283175289  // Read unsigned 8-bit integer (1 BYTE)
175284175290  readU8() {
@@ -175618,23 +175624,138 @@ _readClusterGroups(reader) {
175618175624    const clusterRecordSize = reader.readS64(),
175619175625    minEntry = reader.readU64(),
175620175626    entrySpan = reader.readU64(),
175621-     numClusters = reader.readU32();
175627+     numClusters = reader.readU32(),
175628+     pageListLength = reader.readU64();
175622175629
175623175630    console.log(`Cluster Record Size: ${clusterRecordSize}`);
175624-     console.log(`Min Entry: ${minEntry}, Entry Span: ${entrySpan}, Num Clusters: ${numClusters}`);
175631+     
175632+     // Locator method to get the page list locator offset
175633+     const pageListLocator = this._readLocator(reader);
175634+ 
175635+     console.log('Page Length', pageListLength);
175636+   console.log(`Page List Locator Offset (hex): 0x${pageListLocator.offset.toString(16).toUpperCase()}`);
175637+ 
175638+  const group = {
175639+   minEntry,
175640+   entrySpan,
175641+   numClusters,
175642+   pageListLocator,
175643+   pageListLength
175644+     }; 
175645+     clusterGroups.push(group);
175646+   }
175647+   this.clusterGroups = clusterGroups;
175648+ }
175625175649
175626-     clusterGroups.push({
175627-       minEntry,
175628-       entrySpan,
175629-       numClusters,
175630-     });
175650+ _readLocator(reader) {
175651+   const sizeAndType = reader.readU32();           // 4 bytes: size + T bit
175652+   if ((sizeAndType | 0) < 0)  // | makes the sizeAndType as signed
175653+     throw new Error('Non-standard locators (T=1) not supported yet');
175654+   const size = sizeAndType,            
175655+   offset = reader.readU64();               // 8 bytes: offset
175656+   return {
175657+     size,
175658+     offset
175659+   };
175660+ }
175661+ deserializePageList(page_list_blob){
175662+     if (!page_list_blob)         
175663+       throw new Error('deserializePageList: received an invalid or empty page list blob');
175664+ 
175665+   const reader = new RBufferReader(page_list_blob);  
175666+   this._readEnvelopeMetadata(reader);
175667+   // Page list checksum (64-bit xxhash3)
175668+   const pageListHeaderChecksum = reader.readU64();
175669+   if (pageListHeaderChecksum !== this.headerEnvelopeChecksum)
175670+     throw new Error('RNTuple corrupted: header checksum does not match Page List Header checksum.');
175671+   
175672+ 
175673+   // Read cluster summaries list frame
175674+   const clusterSummaryListSize = reader.readS64();
175675+   if (clusterSummaryListSize>=0) 
175676+     throw new Error('Expected a list frame for cluster summaries');
175677+   const clusterSummaryCount = reader.readU32(),
175678+ 
175679+   clusterSummaries = [];
175680+ 
175681+   for (let i = 0; i < clusterSummaryCount; ++i) {
175682+   const clusterSummaryRecordSize = reader.readS64(), 
175683+   firstEntry = reader.readU64(),
175684+   combined = reader.readU64(),
175685+   flags = combined >> 56n;
175686+   if (flags & 0x01n)
175687+     throw new Error('Cluster summary uses unsupported sharded flag (0x01)');
175688+   const numEntries = Number(combined & 0x00FFFFFFFFFFFFFFn);
175689+   console.log(`Cluster Summary Record Size : ${clusterSummaryRecordSize}`);
175690+   clusterSummaries.push({
175691+     firstEntry,
175692+     numEntries,
175693+     flags
175694+   });
175695+ }
175696+ this.clusterSummaries = clusterSummaries;
175697+ this._readNestedFrames(reader);
175698+ 
175699+ const checksumPagelist = reader.readU64();
175700+ console.log('Page List Checksum', checksumPagelist);
175701+ }
175702+ 
175703+ _readNestedFrames(reader) {
175704+   const clusterPageLocations = [],
175705+  numListClusters = reader.readS64();
175706+  if (numListClusters>=0)
175707+   throw new Error('Expected list frame for clusters');
175708+ const numRecordCluster = reader.readU32();
175709+ 
175710+   for (let i = 0; i < numRecordCluster; ++i) {
175711+     const outerListSize = reader.readS64();
175712+     if (outerListSize >= 0)
175713+       throw new Error('Expected outer list frame for columns');
175714+ 
175715+     const numColumns = reader.readU32(),
175716+     columns = [];
175717+ 
175718+     for (let c = 0; c < numColumns; ++c) {
175719+       const innerListSize = reader.readS64();
175720+       if (innerListSize >= 0)     
175721+         throw new Error('Expected inner list frame for pages');
175722+ 
175723+       const numPages = reader.readU32();
175724+       console.log(`Column ${c} has ${numPages} page(s)`);
175725+      const pages = [];
175726+ 
175727+       for (let p = 0; p < numPages; ++p) {
175728+         const numElementsWithBit = reader.readS32(),
175729+         hasChecksum = numElementsWithBit < 0,
175730+         numElements = BigInt(Math.abs(Number(numElementsWithBit))),
175731+ 
175732+         locator = this._readLocator(reader);
175733+          console.log(`Page ${p} → elements: ${numElements}, checksum: ${hasChecksum}, locator offset: ${locator.offset}, size: ${locator.size}`);
175734+         pages.push({ numElements, hasChecksum, locator });
175735+       }
175736+ 
175737+       const elementOffset = reader.readS64(),
175738+       isSuppressed = elementOffset < 0;
175739+ 
175740+       let compression = null;
175741+       if (!isSuppressed) {
175742+         compression = reader.readU32();
175743+         console.log(`Column ${c} is NOT suppressed, offset: ${elementOffset}, compression: ${compression}`);
175744+       } else 
175745+         console.log(`Column ${c} is suppressed, offset: ${elementOffset}`);
175746+ 
175747+       columns.push({ pages, elementOffset, isSuppressed, compression });
175748+     }
175749+ 
175750+     clusterPageLocations.push(columns);
175631175751  }
175632175752
175633-   this.clusterGroups  = clusterGroups ;
175753+   this.pageLocations  = clusterPageLocations ;
175634175754}
175635175755
175636175756}
175637175757
175758+ 
175638175759/** @summary Very preliminary function to read header/footer from RNTuple
175639175760  * @private */
175640175761async function readHeaderFooter(tuple) {
@@ -175664,8 +175785,30 @@ async function readHeaderFooter(tuple) {
175664175785
175665175786         tuple.builder.deserializeFooter(footer_blob);
175666175787
175667-          return true;
175788+          const group = tuple.builder.clusterGroups?.[0];
175789+          if (!group || !group.pageListLocator)
175790+             throw new Error('No valid cluster group or page list locator found');
175791+ 
175792+          const offset = Number(group.pageListLocator.offset),
175793+                size = Number(group.pageListLocator.size),
175794+                uncompressedSize = Number(group.pageListLength);
175795+ 
175796+          return tuple.$file.readBuffer([offset, size]).then(page_list_blob => {
175797+             if (!(page_list_blob instanceof DataView))
175798+                throw new Error(`Expected DataView from readBuffer, got ${Object.prototype.toString.call(page_list_blob)}`);
175799+ 
175800+             return R__unzip(page_list_blob, uncompressedSize).then(unzipped_blob => {
175801+                if (!(unzipped_blob instanceof DataView))
175802+                   throw new Error(`Unzipped page list is not a DataView, got ${Object.prototype.toString.call(unzipped_blob)}`);
175803+ 
175804+                tuple.builder.deserializePageList(unzipped_blob);
175805+                return true;
175806+             });
175807+          });
175668175808      });
175809+    }).catch(err => {
175810+       console.error('Error during readHeaderFooter execution:', err);
175811+       throw err;
175669175812   });
175670175813}
175671175814
0 commit comments