@xh/hoist 90.0.0 → 90.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/CHANGELOG.md +136 -54
  2. package/admin/columns/Tracking.ts +9 -3
  3. package/admin/tabs/activity/tracking/ActivityTrackingModel.ts +155 -47
  4. package/admin/tabs/activity/tracking/ActivityTrackingPanel.ts +25 -4
  5. package/admin/tabs/activity/tracking/chart/AggChartModel.ts +2 -3
  6. package/appcontainer/ImpersonationBarModel.ts +8 -5
  7. package/build/types/admin/tabs/activity/tracking/ActivityTrackingModel.d.ts +25 -5
  8. package/build/types/cmp/cubegrid/CubeGrid.d.ts +26 -0
  9. package/build/types/cmp/cubegrid/CubeGridModel.d.ts +103 -0
  10. package/build/types/cmp/cubegrid/CubeGridPivotModel.d.ts +181 -0
  11. package/build/types/cmp/cubegrid/Types.d.ts +85 -0
  12. package/build/types/cmp/cubegrid/index.d.ts +4 -0
  13. package/build/types/cmp/dataview/DataViewModel.d.ts +6 -10
  14. package/build/types/cmp/grid/GridModel.d.ts +8 -33
  15. package/build/types/cmp/grid/Types.d.ts +51 -1
  16. package/build/types/cmp/grid/columns/Column.d.ts +2 -1
  17. package/build/types/cmp/grid/columns/ColumnGroup.d.ts +6 -0
  18. package/build/types/cmp/grid/helpers/GridCountLabel.d.ts +6 -3
  19. package/build/types/cmp/grid/impl/ColumnWidthCalculator.d.ts +6 -0
  20. package/build/types/cmp/grid/impl/GridLikeModel.d.ts +3 -0
  21. package/build/types/cmp/grid/impl/MenuSupport.d.ts +13 -0
  22. package/build/types/cmp/pdfviewer/PdfViewer.d.ts +14 -0
  23. package/build/types/cmp/pdfviewer/PdfViewerModel.d.ts +150 -0
  24. package/build/types/cmp/pdfviewer/Types.d.ts +55 -0
  25. package/build/types/cmp/pdfviewer/impl/PdfFindInputModel.d.ts +14 -0
  26. package/build/types/cmp/pdfviewer/impl/PdfViewerToolbarModel.d.ts +34 -0
  27. package/build/types/cmp/pdfviewer/impl/ZoomOptions.d.ts +10 -0
  28. package/build/types/cmp/pdfviewer/index.d.ts +3 -0
  29. package/build/types/cmp/statcard/StatCard.d.ts +90 -0
  30. package/build/types/cmp/statcard/index.d.ts +1 -0
  31. package/build/types/cmp/store/StoreFilterField.d.ts +8 -9
  32. package/build/types/cmp/store/impl/StoreFilterFieldImplModel.d.ts +4 -4
  33. package/build/types/cmp/zoneGrid/ZoneGridModel.d.ts +6 -10
  34. package/build/types/core/types/Types.d.ts +6 -0
  35. package/build/types/data/Field.d.ts +8 -1
  36. package/build/types/data/Store.d.ts +12 -0
  37. package/build/types/data/cube/Cube.d.ts +2 -0
  38. package/build/types/data/cube/CubeField.d.ts +3 -2
  39. package/build/types/data/cube/Query.d.ts +66 -4
  40. package/build/types/data/cube/View.d.ts +82 -4
  41. package/build/types/data/cube/ViewRowData.d.ts +13 -0
  42. package/build/types/data/cube/aggregate/MedianAggregator.d.ts +19 -0
  43. package/build/types/data/cube/aggregate/SumIfSameAggregator.d.ts +30 -0
  44. package/build/types/data/cube/impl/RowCache.d.ts +5 -0
  45. package/build/types/data/cube/impl/RowDataGenerator.d.ts +26 -0
  46. package/build/types/data/cube/impl/ViewDiagnostics.d.ts +27 -0
  47. package/build/types/data/cube/pivot/PivotCellRow.d.ts +27 -0
  48. package/build/types/data/cube/pivot/PivotPath.d.ts +45 -0
  49. package/build/types/data/cube/pivot/impl/PivotCells.d.ts +111 -0
  50. package/build/types/data/cube/pivot/impl/PivotReference.d.ts +39 -0
  51. package/build/types/data/cube/pivot/impl/PivotStructure.d.ts +105 -0
  52. package/build/types/data/cube/row/BaseRow.d.ts +12 -0
  53. package/build/types/data/cube/row/LeafRow.d.ts +4 -4
  54. package/build/types/data/cube/row/ParentRow.d.ts +20 -4
  55. package/build/types/data/cube/row/RowUpdate.d.ts +2 -0
  56. package/build/types/data/index.d.ts +3 -0
  57. package/build/types/desktop/cmp/button/grid/ColAutosizeButton.d.ts +6 -3
  58. package/build/types/desktop/cmp/button/grid/ColChooserButton.d.ts +7 -3
  59. package/build/types/desktop/cmp/button/grid/ExpandToLevelButton.d.ts +6 -3
  60. package/build/types/desktop/cmp/button/grid/ExportButton.d.ts +6 -3
  61. package/build/types/desktop/cmp/grid/find/GridFindField.d.ts +8 -9
  62. package/build/types/desktop/cmp/grid/find/impl/GridFindFieldImplModel.d.ts +3 -4
  63. package/build/types/desktop/cmp/pdfviewer/impl/PdfViewerToolbar.d.ts +12 -0
  64. package/build/types/desktop/cmp/statcard/impl/StatCardInfoImpl.d.ts +12 -0
  65. package/build/types/dynamics/desktop.d.ts +2 -0
  66. package/build/types/dynamics/mobile.d.ts +1 -0
  67. package/build/types/icon/Icon.d.ts +12 -0
  68. package/build/types/kit/pdfjs/index.d.ts +23 -0
  69. package/build/types/kit/pdfjs/styles.d.ts +2 -0
  70. package/build/types/kit/swiper/index.d.ts +7 -7
  71. package/build/types/mobile/cmp/button/grid/ColAutosizeButton.d.ts +6 -3
  72. package/build/types/mobile/cmp/button/grid/ColChooserButton.d.ts +6 -3
  73. package/build/types/mobile/cmp/button/grid/ExpandCollapseButton.d.ts +4 -4
  74. package/build/types/mobile/cmp/button/grid/ExpandToLevelButton.d.ts +4 -4
  75. package/build/types/mobile/cmp/pdfviewer/impl/PdfViewerToolbar.d.ts +12 -0
  76. package/cmp/README.md +3 -0
  77. package/cmp/ag-grid/AgGrid.ts +25 -3
  78. package/cmp/cubegrid/CubeGrid.ts +60 -0
  79. package/cmp/cubegrid/CubeGridModel.ts +365 -0
  80. package/cmp/cubegrid/CubeGridPivotModel.ts +943 -0
  81. package/cmp/cubegrid/README.md +343 -0
  82. package/cmp/cubegrid/Types.ts +105 -0
  83. package/cmp/cubegrid/index.ts +10 -0
  84. package/cmp/dataview/DataViewModel.ts +13 -8
  85. package/cmp/grid/Grid.scss +21 -5
  86. package/cmp/grid/GridModel.ts +41 -47
  87. package/cmp/grid/Types.ts +58 -1
  88. package/cmp/grid/columns/Column.ts +3 -1
  89. package/cmp/grid/columns/ColumnGroup.ts +10 -0
  90. package/cmp/grid/helpers/GridCountLabel.ts +12 -5
  91. package/cmp/grid/impl/ColumnGroupHeader.ts +18 -4
  92. package/cmp/grid/impl/ColumnWidthCalculator.ts +24 -0
  93. package/cmp/grid/impl/GridLikeModel.ts +17 -0
  94. package/cmp/grid/impl/MenuSupport.ts +36 -20
  95. package/cmp/pdfviewer/PdfViewer.scss +48 -0
  96. package/cmp/pdfviewer/PdfViewer.ts +102 -0
  97. package/cmp/pdfviewer/PdfViewerModel.ts +641 -0
  98. package/cmp/pdfviewer/README.md +224 -0
  99. package/cmp/pdfviewer/Types.ts +72 -0
  100. package/cmp/pdfviewer/impl/PdfFindInputModel.ts +44 -0
  101. package/cmp/pdfviewer/impl/PdfViewerToolbarModel.ts +45 -0
  102. package/cmp/pdfviewer/impl/ZoomOptions.ts +36 -0
  103. package/cmp/pdfviewer/index.ts +9 -0
  104. package/cmp/statcard/StatCard.scss +181 -0
  105. package/cmp/statcard/StatCard.ts +320 -0
  106. package/cmp/statcard/index.ts +1 -0
  107. package/cmp/store/StoreFilterField.ts +8 -9
  108. package/cmp/store/impl/StoreFilterFieldImplModel.ts +14 -14
  109. package/cmp/zoneGrid/ZoneGridModel.ts +13 -8
  110. package/core/types/Types.ts +7 -0
  111. package/data/Field.ts +10 -0
  112. package/data/Store.ts +25 -2
  113. package/data/cube/Cube.ts +5 -0
  114. package/data/cube/CubeField.ts +5 -0
  115. package/data/cube/Query.ts +170 -17
  116. package/data/cube/README.md +77 -2
  117. package/data/cube/View.ts +211 -32
  118. package/data/cube/ViewRowData.ts +22 -0
  119. package/data/cube/aggregate/MedianAggregator.ts +88 -0
  120. package/data/cube/aggregate/SumIfSameAggregator.ts +128 -0
  121. package/data/cube/impl/RowCache.ts +32 -11
  122. package/data/cube/impl/RowDataGenerator.ts +96 -4
  123. package/data/cube/impl/ViewDiagnostics.ts +47 -0
  124. package/data/cube/pivot/PivotCellRow.ts +73 -0
  125. package/data/cube/pivot/PivotPath.ts +67 -0
  126. package/data/cube/pivot/impl/PivotCells.ts +538 -0
  127. package/data/cube/pivot/impl/PivotReference.ts +125 -0
  128. package/data/cube/pivot/impl/PivotStructure.ts +500 -0
  129. package/data/cube/row/BaseRow.ts +26 -0
  130. package/data/cube/row/LeafRow.ts +9 -8
  131. package/data/cube/row/ParentRow.ts +58 -25
  132. package/data/cube/row/RowUpdate.ts +8 -0
  133. package/data/index.ts +3 -0
  134. package/desktop/appcontainer/AppContainer.ts +5 -1
  135. package/desktop/cmp/button/grid/ColAutosizeButton.ts +21 -5
  136. package/desktop/cmp/button/grid/ColChooserButton.ts +11 -5
  137. package/desktop/cmp/button/grid/ExpandToLevelButton.ts +20 -5
  138. package/desktop/cmp/button/grid/ExportButton.ts +19 -7
  139. package/desktop/cmp/dash/canvas/DashCanvas.ts +26 -2
  140. package/desktop/cmp/grid/find/GridFindField.ts +8 -9
  141. package/desktop/cmp/grid/find/impl/GridFindFieldImplModel.ts +15 -16
  142. package/desktop/cmp/grid/impl/colchooser/ColChooserBucketModel.ts +1 -1
  143. package/desktop/cmp/pdfviewer/impl/PdfViewerToolbar.ts +190 -0
  144. package/desktop/cmp/statcard/impl/StatCardInfoImpl.ts +27 -0
  145. package/docs/README.md +6 -2
  146. package/docs/doc-registry.json +21 -5
  147. package/docs/upgrade-notes/v90-upgrade-notes.md +130 -0
  148. package/docs/version-compatibility.md +2 -1
  149. package/dynamics/desktop.ts +4 -0
  150. package/dynamics/mobile.ts +2 -0
  151. package/format/FormatNumber.ts +6 -2
  152. package/icon/Icon.ts +18 -0
  153. package/icon/index.ts +32 -0
  154. package/kit/README.md +2 -0
  155. package/kit/pdfjs/PdfJs.scss +25 -0
  156. package/kit/pdfjs/index.ts +103 -0
  157. package/kit/pdfjs/pdf_viewer.css +6481 -0
  158. package/kit/pdfjs/styles.ts +12 -0
  159. package/mcp/README.md +13 -0
  160. package/mcp/data/import-paths.ts +4 -8
  161. package/mcp/data/index-cache.ts +2 -1
  162. package/mcp/data/ts-registry.ts +8 -29
  163. package/mcp/util/paths.ts +26 -0
  164. package/mobile/appcontainer/AppContainer.ts +3 -1
  165. package/mobile/cmp/button/grid/ColAutosizeButton.ts +20 -5
  166. package/mobile/cmp/button/grid/ColChooserButton.ts +12 -5
  167. package/mobile/cmp/button/grid/ExpandCollapseButton.ts +10 -6
  168. package/mobile/cmp/button/grid/ExpandToLevelButton.ts +10 -6
  169. package/mobile/cmp/pdfviewer/impl/PdfViewerToolbar.ts +137 -0
  170. package/package.json +14 -8
  171. package/public/msal-redirect-bridge.min.js +1 -1
  172. package/styles/vars.scss +59 -0
package/icon/index.ts CHANGED
@@ -147,6 +147,8 @@ import {
147
147
  faListTree as faListTreeLight,
148
148
  faLock as faLockLight,
149
149
  faLockOpen as faLockOpenLight,
150
+ faMagnifyingGlassMinus as faMagnifyingGlassMinusLight,
151
+ faMagnifyingGlassPlus as faMagnifyingGlassPlusLight,
150
152
  faMapMarkerAlt as faMapMarkerAltLight,
151
153
  faMapSigns as faMapSignsLight,
152
154
  faMask as faMaskLight,
@@ -174,6 +176,7 @@ import {
174
176
  faRectangleTerminal as faRectangleTerminalLight,
175
177
  faRedo as faRedoLight,
176
178
  faRocket as faRocketLight,
179
+ faRotateRight as faRotateRightLight,
177
180
  faUserShield as faUserShieldLight,
178
181
  faSave as faSaveLight,
179
182
  faSearch as faSearchLight,
@@ -202,6 +205,7 @@ import {
202
205
  faSync as faSyncLight,
203
206
  faTable as faTableLight,
204
207
  faTableLayout as faTableLayoutLight,
208
+ faTablePivot as faTablePivotLight,
205
209
  faTag as faTagLight,
206
210
  faTags as faTagsLight,
207
211
  faTh as faThLight,
@@ -368,6 +372,8 @@ import {
368
372
  faListTree,
369
373
  faLock,
370
374
  faLockOpen,
375
+ faMagnifyingGlassMinus,
376
+ faMagnifyingGlassPlus,
371
377
  faMapMarkerAlt,
372
378
  faMapSigns,
373
379
  faMask,
@@ -395,6 +401,7 @@ import {
395
401
  faRectangleTerminal,
396
402
  faRedo,
397
403
  faRocket,
404
+ faRotateRight,
398
405
  faUserShield,
399
406
  faSave,
400
407
  faSearch,
@@ -422,6 +429,7 @@ import {
422
429
  faSync,
423
430
  faTable,
424
431
  faTableLayout,
432
+ faTablePivot,
425
433
  faTag,
426
434
  faTags,
427
435
  faTh,
@@ -589,6 +597,8 @@ import {
589
597
  faListTree as faListTreeSolid,
590
598
  faLock as faLockSolid,
591
599
  faLockOpen as faLockOpenSolid,
600
+ faMagnifyingGlassMinus as faMagnifyingGlassMinusSolid,
601
+ faMagnifyingGlassPlus as faMagnifyingGlassPlusSolid,
592
602
  faMapMarkerAlt as faMapMarkerAltSolid,
593
603
  faMapSigns as faMapSignsSolid,
594
604
  faMask as faMaskSolid,
@@ -616,6 +626,7 @@ import {
616
626
  faRectangleTerminal as faRectangleTerminalSolid,
617
627
  faRedo as faRedoSolid,
618
628
  faRocket as faRocketSolid,
629
+ faRotateRight as faRotateRightSolid,
619
630
  faUserShield as faUserShieldSolid,
620
631
  faSave as faSaveSolid,
621
632
  faSearch as faSearchSolid,
@@ -644,6 +655,7 @@ import {
644
655
  faSync as faSyncSolid,
645
656
  faTable as faTableSolid,
646
657
  faTableLayout as faTableLayoutSolid,
658
+ faTablePivot as faTablePivotSolid,
647
659
  faTag as faTagSolid,
648
660
  faTags as faTagsSolid,
649
661
  faTh as faThSolid,
@@ -811,6 +823,8 @@ import {
811
823
  faListTree as faListTreeThin,
812
824
  faLock as faLockThin,
813
825
  faLockOpen as faLockOpenThin,
826
+ faMagnifyingGlassMinus as faMagnifyingGlassMinusThin,
827
+ faMagnifyingGlassPlus as faMagnifyingGlassPlusThin,
814
828
  faMapMarkerAlt as faMapMarkerAltThin,
815
829
  faMapSigns as faMapSignsThin,
816
830
  faMask as faMaskThin,
@@ -838,6 +852,7 @@ import {
838
852
  faRectangleTerminal as faRectangleTerminalThin,
839
853
  faRedo as faRedoThin,
840
854
  faRocket as faRocketThin,
855
+ faRotateRight as faRotateRightThin,
841
856
  faUserShield as faUserShieldThin,
842
857
  faSave as faSaveThin,
843
858
  faSearch as faSearchThin,
@@ -866,6 +881,7 @@ import {
866
881
  faSync as faSyncThin,
867
882
  faTable as faTableThin,
868
883
  faTableLayout as faTableLayoutThin,
884
+ faTablePivot as faTablePivotThin,
869
885
  faTag as faTagThin,
870
886
  faTags as faTagsThin,
871
887
  faTh as faThThin,
@@ -1444,6 +1460,14 @@ library.add(
1444
1460
  faWandMagicSparklesLight,
1445
1461
  faWandMagicSparklesSolid,
1446
1462
  faWandMagicSparklesThin,
1463
+ faMagnifyingGlassMinus,
1464
+ faMagnifyingGlassMinusLight,
1465
+ faMagnifyingGlassMinusSolid,
1466
+ faMagnifyingGlassMinusThin,
1467
+ faMagnifyingGlassPlus,
1468
+ faMagnifyingGlassPlusLight,
1469
+ faMagnifyingGlassPlusSolid,
1470
+ faMagnifyingGlassPlusThin,
1447
1471
  faMapMarkerAlt,
1448
1472
  faMapMarkerAltLight,
1449
1473
  faMapMarkerAltSolid,
@@ -1552,6 +1576,10 @@ library.add(
1552
1576
  faRocketLight,
1553
1577
  faRocketSolid,
1554
1578
  faRocketThin,
1579
+ faRotateRight,
1580
+ faRotateRightLight,
1581
+ faRotateRightSolid,
1582
+ faRotateRightThin,
1555
1583
  faUserShield,
1556
1584
  faUserShieldLight,
1557
1585
  faUserShieldSolid,
@@ -1668,6 +1696,10 @@ library.add(
1668
1696
  faTableLayoutLight,
1669
1697
  faTableLayoutSolid,
1670
1698
  faTableLayoutThin,
1699
+ faTablePivot,
1700
+ faTablePivotLight,
1701
+ faTablePivotSolid,
1702
+ faTablePivotThin,
1671
1703
  faGaugeHigh,
1672
1704
  faGaugeHighLight,
1673
1705
  faGaugeHighSolid,
package/kit/README.md CHANGED
@@ -25,6 +25,7 @@ kit/
25
25
  ├── blueprint/ # Blueprint 6 wrappers, element factories, disabled transitions
26
26
  ├── golden-layout/ # GoldenLayout v1.5.9 with React 18 patches
27
27
  ├── highcharts/ # Highcharts install function with default config
28
+ ├── pdfjs/ # Lazy loader for pdf.js (optional peer dependency)
28
29
  ├── react-beautiful-dnd/ # Drag-and-drop re-exports with element factories
29
30
  ├── react-day-picker/ # Calendar for desktop and mobile DateInput, with shared theme
30
31
  ├── react-dropzone/ # File drop zone re-export
@@ -133,6 +134,7 @@ with several patches applied directly to GoldenLayout's internal classes:
133
134
 
134
135
  | Library | Kit Sub-package | Used By | Purpose |
135
136
  |---------|-----------------|---------|---------|
137
+ | pdf.js (`pdfjs-dist`) | `pdfjs/` | PdfViewer | Loaded on first use. Optional peer - apps add it to opt in. See [`/cmp/pdfviewer/`](../cmp/pdfviewer/README.md) |
136
138
  | react-beautiful-dnd | `react-beautiful-dnd/` | DashCanvas widget reordering | Drag-and-drop with `DragDropContext`, `Droppable`, `Draggable` |
137
139
  | react-day-picker | `react-day-picker/` | Desktop and mobile DateInput | `DayPicker` calendar (v10) and the stylesheet that themes it for both platforms |
138
140
  | react-dropzone | `react-dropzone/` | FileChooser | File drop zone via `Dropzone` component |
@@ -0,0 +1,25 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2026 Extremely Heavy Industries Inc.
6
+ */
7
+
8
+ // Hoist overrides for the scoped pdf.js styles in pdf_viewer.css. Loaded after that file, so
9
+ // these win at equal or higher specificity.
10
+ .xh-pdf-viewer .pdfViewer {
11
+ padding: var(--xh-pdf-viewer-page-gap-px) 0;
12
+
13
+ &.removePageBorders .page {
14
+ margin: 0 auto var(--xh-pdf-viewer-page-gap-px);
15
+ box-shadow: var(--xh-pdf-viewer-page-shadow);
16
+ }
17
+
18
+ // Leave forced-colors (high contrast) mode to pdf.js, which swaps these fills for a filter.
19
+ @media (forced-colors: none) {
20
+ .textLayer .highlight {
21
+ --highlight-bg-color: var(--xh-pdf-viewer-highlight-bg);
22
+ --highlight-selected-bg-color: var(--xh-pdf-viewer-highlight-selected-bg);
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,103 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2026 Extremely Heavy Industries Inc.
6
+ */
7
+ import {checkVersion} from '@xh/hoist/utils/js';
8
+ import type * as PdfJsLibModule from 'pdfjs-dist/legacy/build/pdf.mjs';
9
+ import type * as PdfJsViewerLibModule from 'pdfjs-dist/legacy/web/pdf_viewer.mjs';
10
+
11
+ export type PdfJsLib = typeof PdfJsLibModule;
12
+ export type PdfJsViewerLib = typeof PdfJsViewerLibModule;
13
+
14
+ /** The pdf.js core and viewer component libraries, loaded on demand. */
15
+ export interface PdfJs {
16
+ lib: PdfJsLib;
17
+ viewer: PdfJsViewerLib;
18
+ /** Shared worker for parsing documents - pass to `getDocument()`. */
19
+ worker: InstanceType<PdfJsLib['PDFWorker']>;
20
+ /** Supplies wasm decoders and fonts to pdf.js - pass to `getDocument()`. */
21
+ BinaryDataFactory: any;
22
+ }
23
+
24
+ const MIN_VERSION = '6.3.0';
25
+ const MAX_VERSION = '6.*.*';
26
+
27
+ let loadPromise: Promise<PdfJs> = null;
28
+
29
+ /**
30
+ * Load pdf.js on first use. Apps opt in by adding `pdfjs-dist` to their own dependencies -
31
+ * Hoist declares it as an optional peer dependency.
32
+ *
33
+ * The library, its worker, and its CSS are split into separate chunks by the app bundler and
34
+ * fetched only when a PDF is first displayed. No app-side bootstrap or build config is required.
35
+ *
36
+ * Uses the pdf.js "legacy" build, which supports a wider range of browsers than its modern build.
37
+ */
38
+ export function loadPdfJsAsync(): Promise<PdfJs> {
39
+ loadPromise ??= loadInternalAsync().catch(e => {
40
+ loadPromise = null;
41
+ throw e;
42
+ });
43
+ return loadPromise;
44
+ }
45
+
46
+ //------------------
47
+ // Implementation
48
+ //------------------
49
+ async function loadInternalAsync(): Promise<PdfJs> {
50
+ // The viewer module reads `globalThis.pdfjsLib`, set by the core module - load in sequence.
51
+ const lib = await import('pdfjs-dist/legacy/build/pdf.mjs'),
52
+ {version} = lib;
53
+ if (!checkVersion(version, MIN_VERSION, MAX_VERSION)) {
54
+ throw new Error(
55
+ `This version of Hoist requires a pdfjs-dist version between ${MIN_VERSION} and ` +
56
+ `${MAX_VERSION}. Version ${version} detected.`
57
+ );
58
+ }
59
+
60
+ const [viewer] = await Promise.all([
61
+ import('pdfjs-dist/legacy/web/pdf_viewer.mjs'),
62
+ import('./styles')
63
+ ]);
64
+
65
+ // Let the app bundler emit the worker as its own chunk. Serving the raw `.mjs` file would
66
+ // rely on servers sending `.mjs` with a JS MIME type. One worker serves all documents for
67
+ // the life of the app - pdf.js leaves a caller-supplied worker running when a document closes.
68
+ const port = new Worker(
69
+ new URL('pdfjs-dist/legacy/build/pdf.worker.min.mjs', import.meta.url),
70
+ {type: 'module'}
71
+ ),
72
+ worker = lib.PDFWorker.create({port});
73
+
74
+ return {lib, viewer, worker, BinaryDataFactory: HoistBinaryDataFactory};
75
+ }
76
+
77
+ /**
78
+ * Binary assets pdf.js may request while parsing a document, resolved by the app bundler.
79
+ * Wasm decoders cover JPEG2000 and JBIG2 images, common in scanned documents. The two fonts are
80
+ * the only standard fonts pdf.js fetches when `useSystemFonts` is enabled (the browser default).
81
+ */
82
+ const BINARY_ASSETS: Record<string, URL> = {
83
+ 'openjpeg.wasm': new URL('pdfjs-dist/wasm/openjpeg.wasm', import.meta.url),
84
+ 'jbig2.wasm': new URL('pdfjs-dist/wasm/jbig2.wasm', import.meta.url),
85
+ 'FoxitSymbol.pfb': new URL('pdfjs-dist/standard_fonts/FoxitSymbol.pfb', import.meta.url),
86
+ 'FoxitDingbats.pfb': new URL('pdfjs-dist/standard_fonts/FoxitDingbats.pfb', import.meta.url)
87
+ };
88
+
89
+ /**
90
+ * Implements the pdf.js `BinaryDataFactory` contract over {@link BINARY_ASSETS}. Passing a
91
+ * custom factory also tells pdf.js to route these requests through the main thread, so they
92
+ * are served from the app's own origin like any other bundled asset.
93
+ */
94
+ class HoistBinaryDataFactory {
95
+ async fetch({kind, filename}: {kind: string; filename: string}): Promise<Uint8Array> {
96
+ const url = BINARY_ASSETS[filename];
97
+ if (!url) throw new Error(`PDF ${kind} asset '${filename}' is not available.`);
98
+
99
+ const response = await fetch(url);
100
+ if (!response.ok) throw new Error(`Unable to load PDF asset at ${url}.`);
101
+ return new Uint8Array(await response.arrayBuffer());
102
+ }
103
+ }