@a3s-lab/office 0.12.0 → 0.13.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 (111) hide show
  1. package/README.md +99 -6
  2. package/dist/0~1403.js +20 -12
  3. package/dist/0~2805.js +241 -241
  4. package/dist/0~4980.js +1 -1
  5. package/dist/0~5050.js +1 -20
  6. package/dist/0~5093.js +547 -547
  7. package/dist/0~7048.js +31 -29
  8. package/dist/0~document-editor.js +694 -90
  9. package/dist/0~pdf-viewer.js +41 -10
  10. package/dist/0~presentation-editor.js +8 -6
  11. package/dist/0~spreadsheet-editor.js +11528 -10094
  12. package/dist/0~work-document-import-worker-client.js +237 -0
  13. package/dist/0~work-docx-export.js +1 -1
  14. package/dist/0~work-docx-import.js +1 -1
  15. package/dist/0~work-docx-large-document-import.js +559 -0
  16. package/dist/0~work-office-diagnostics.js +46 -32
  17. package/dist/4104.js +4092 -3210
  18. package/dist/432.js +51 -7
  19. package/dist/4476.js +201 -7
  20. package/dist/5184.js +24 -2
  21. package/dist/{8928.js → 6282.js} +2338 -93
  22. package/dist/8715.js +895 -888
  23. package/dist/9356.js +3 -1
  24. package/dist/core.js +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/internal/features/work/editors/document-editor-support.d.ts +1 -9
  27. package/dist/internal/features/work/editors/document-external-content.d.ts +1 -1
  28. package/dist/internal/features/work/editors/presentation-slide-canvas.d.ts +3 -1
  29. package/dist/internal/features/work/editors/presentation-slide-thumbnail.d.ts +3 -2
  30. package/dist/internal/features/work/editors/presentation-thumbnail-rail.d.ts +2 -1
  31. package/dist/internal/features/work/editors/presentation-workspace.d.ts +2 -1
  32. package/dist/internal/features/work/editors/spreadsheet-border-ribbon.d.ts +5 -0
  33. package/dist/internal/features/work/editors/spreadsheet-calculation-projection.d.ts +10 -0
  34. package/dist/internal/features/work/editors/spreadsheet-cell-border-command.d.ts +3 -0
  35. package/dist/internal/features/work/editors/spreadsheet-cell-border.d.ts +14 -0
  36. package/dist/internal/features/work/editors/spreadsheet-cell-fill-command.d.ts +3 -0
  37. package/dist/internal/features/work/editors/spreadsheet-cell-fill.d.ts +12 -0
  38. package/dist/internal/features/work/editors/spreadsheet-cell-range.d.ts +14 -0
  39. package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +159 -0
  40. package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +8 -4
  41. package/dist/internal/features/work/editors/spreadsheet-editor-support.d.ts +8 -2
  42. package/dist/internal/features/work/editors/spreadsheet-home-format-ribbon.d.ts +10 -0
  43. package/dist/internal/features/work/editors/spreadsheet-in-place-workbook-sync.d.ts +10 -0
  44. package/dist/internal/features/work/editors/spreadsheet-operation-projection.d.ts +14 -0
  45. package/dist/internal/features/work/editors/spreadsheet-structure-selection.d.ts +7 -0
  46. package/dist/internal/features/work/editors/use-document-pagination.d.ts +5 -0
  47. package/dist/internal/features/work/editors/use-presentation-design-commands.d.ts +2 -1
  48. package/dist/internal/features/work/editors/use-spreadsheet-workbook-sync.d.ts +2 -1
  49. package/dist/internal/features/work/spreadsheet-history-value.d.ts +1 -0
  50. package/dist/internal/features/work/spreadsheet-sparse.d.ts +6 -1
  51. package/dist/internal/features/work/work-document-chunk-geometry.d.ts +28 -0
  52. package/dist/internal/features/work/work-document-chunk-node.d.ts +23 -0
  53. package/dist/internal/features/work/work-document-extensions.d.ts +1 -0
  54. package/dist/internal/features/work/work-document-html-fingerprint.d.ts +15 -0
  55. package/dist/internal/features/work/work-document-import-worker-client.d.ts +13 -0
  56. package/dist/internal/features/work/work-document-import-worker-protocol.d.ts +36 -0
  57. package/dist/internal/features/work/work-document-import.worker.d.ts +1 -0
  58. package/dist/internal/features/work/work-document-incremental-layout.d.ts +1 -1
  59. package/dist/internal/features/work/work-document-integrity-index.d.ts +14 -0
  60. package/dist/internal/features/work/work-document-lazy-block.d.ts +3 -0
  61. package/dist/internal/features/work/work-document-lazy-html.d.ts +21 -0
  62. package/dist/internal/features/work/work-document-lazy-model.d.ts +29 -0
  63. package/dist/internal/features/work/work-document-lazy-pagination-measurement.d.ts +3 -0
  64. package/dist/internal/features/work/work-document-lazy-preview.d.ts +21 -0
  65. package/dist/internal/features/work/work-document-lazy-update.d.ts +14 -0
  66. package/dist/internal/features/work/work-document-model.d.ts +18 -2
  67. package/dist/internal/features/work/work-document-page-surface-registry.d.ts +16 -0
  68. package/dist/internal/features/work/work-document-pagination-dom.d.ts +1 -0
  69. package/dist/internal/features/work/work-document-pagination-types.d.ts +1 -0
  70. package/dist/internal/features/work/work-document-pagination.d.ts +1 -1
  71. package/dist/internal/features/work/work-document-text-statistics.d.ts +25 -0
  72. package/dist/internal/features/work/work-document-windowing.d.ts +23 -0
  73. package/dist/internal/features/work/work-docx-large-document-import.d.ts +35 -0
  74. package/dist/internal/features/work/work-docx-large-document-parser.d.ts +29 -0
  75. package/dist/internal/features/work/work-file-import.d.ts +5 -0
  76. package/dist/internal/features/work/work-file-io.d.ts +3 -3
  77. package/dist/internal/features/work/work-file-kind.d.ts +5 -0
  78. package/dist/internal/features/work/work-office-diagnostics.d.ts +10 -1
  79. package/dist/internal/features/work/work-ooxml-package.d.ts +8 -0
  80. package/dist/internal/features/work/work-presentation-layouts.d.ts +7 -1
  81. package/dist/internal/features/work/work-repository.d.ts +1 -0
  82. package/dist/internal/features/work/work-spreadsheet-compatibility-summary.d.ts +10 -0
  83. package/dist/internal/features/work/work-spreadsheet-file-export.d.ts +2 -0
  84. package/dist/internal/features/work/work-spreadsheet-file-import.d.ts +3 -0
  85. package/dist/internal/features/work/work-spreadsheet-import-diagnostics.d.ts +2 -0
  86. package/dist/internal/features/work/work-spreadsheet-import-worker-client.d.ts +6 -0
  87. package/dist/internal/features/work/work-spreadsheet-import-worker-protocol.d.ts +32 -0
  88. package/dist/internal/features/work/work-spreadsheet-import.worker.d.ts +1 -0
  89. package/dist/internal/features/work/work-spreadsheet-matrix-profile.d.ts +64 -0
  90. package/dist/internal/features/work/work-spreadsheet-package-scan-worker-client.d.ts +6 -0
  91. package/dist/internal/features/work/work-spreadsheet-package-scan-worker-protocol.d.ts +49 -0
  92. package/dist/internal/features/work/work-spreadsheet-package-scan.worker.d.ts +1 -0
  93. package/dist/internal/features/work/work-xlsx-formula-diagnostics.d.ts +3 -1
  94. package/dist/internal/features/work/work-xlsx-formulas.d.ts +2 -1
  95. package/dist/internal/features/work/work-xlsx-interop.d.ts +6 -5
  96. package/dist/internal/features/work/work-xlsx-pivot-diagnostics.d.ts +2 -1
  97. package/dist/internal/features/work/work-xlsx-plain-fast-path.d.ts +54 -0
  98. package/dist/internal/features/work/work-xlsx-style-gate.d.ts +1 -0
  99. package/dist/internal/features/work/work-xlsx-worksheet-scan.d.ts +12 -0
  100. package/dist/internal/features/work/work-xlsx-worksheet.d.ts +12 -0
  101. package/dist/office-kernel.wasm +0 -0
  102. package/dist/office-kernel.worker.js +31 -29
  103. package/dist/react.d.ts +7 -1
  104. package/dist/styles.css +440 -3
  105. package/dist/work-document-import.worker.js +558 -0
  106. package/dist/work-spreadsheet-import.worker.js +24745 -0
  107. package/dist/work-spreadsheet-import.worker.js.LICENSE.txt +3 -0
  108. package/dist/work-spreadsheet-package-scan.worker.js +4157 -0
  109. package/dist/work-spreadsheet-package-scan.worker.js.LICENSE.txt +11 -0
  110. package/docs/latest/en/browser-editor-architecture.md +351 -15
  111. package/package.json +19 -1
@@ -0,0 +1,64 @@
1
+ import type { Cell, CellMatrix } from '@fortune-sheet/core';
2
+ export declare const SPREADSHEET_SHOWN_COMMENT_CELLS_PROPERTY = "__a3sShownCommentCells";
3
+ export interface SpreadsheetMatrixProfile {
4
+ columnCount: number;
5
+ formulaCells: readonly Readonly<{
6
+ column: number;
7
+ row: number;
8
+ }>[];
9
+ fortuneReady: boolean;
10
+ historyRoot: object;
11
+ historyState: object;
12
+ populatedCellCount: number;
13
+ protectionCellKey: string;
14
+ rowCount: number;
15
+ shownCommentCells: readonly Readonly<{
16
+ c: number;
17
+ r: number;
18
+ }>[];
19
+ }
20
+ export interface SpreadsheetMatrixCellChange {
21
+ column: number;
22
+ current: Cell | null | undefined;
23
+ previous: Cell | null | undefined;
24
+ row: number;
25
+ }
26
+ interface ImportedSpreadsheetMatrixOptions {
27
+ columnCount: number;
28
+ formulaCells: readonly Readonly<{
29
+ column: number;
30
+ row: number;
31
+ }>[];
32
+ fortuneReady: boolean;
33
+ populatedCellCount: number;
34
+ protectionCellKey: string;
35
+ rowCount: number;
36
+ shownCommentCells: readonly Readonly<{
37
+ c: number;
38
+ r: number;
39
+ }>[];
40
+ }
41
+ /**
42
+ * Freezes a package-owned import cell before it becomes controlled content.
43
+ * Fortune can then share the cell as an Immer base value without recursively
44
+ * freezing or cloning every populated cell during editor initialization.
45
+ */
46
+ export declare function freezeImportedSpreadsheetCell(cell: Cell): Cell;
47
+ /**
48
+ * Authenticates a normalized, package-owned matrix for clone-free projection.
49
+ * The registry is identity-based, so an edited or host-created matrix cannot
50
+ * accidentally inherit the optimization.
51
+ */
52
+ export declare function registerImportedSpreadsheetMatrix(data: CellMatrix, options: ImportedSpreadsheetMatrixOptions): void;
53
+ /**
54
+ * Carries import-time summaries across a bounded cell edit without rescanning
55
+ * the complete matrix. The source identity must have been authenticated by
56
+ * this package and must already be directly consumable by Fortune.
57
+ */
58
+ export declare function registerDerivedSpreadsheetMatrix(data: CellMatrix, source: CellMatrix, changes: readonly SpreadsheetMatrixCellChange[]): boolean;
59
+ export declare function spreadsheetMatrixProfile(data: CellMatrix | undefined): SpreadsheetMatrixProfile | undefined;
60
+ export declare function attachSpreadsheetShownCommentCells(data: CellMatrix, cells: readonly Readonly<{
61
+ c: number;
62
+ r: number;
63
+ }>[]): void;
64
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { SpreadsheetPackageScanResult } from './work-spreadsheet-package-scan-worker-protocol';
2
+ /**
3
+ * Decompresses and classifies worksheet XML away from the UI thread. A null
4
+ * result preserves the existing main-thread parser as a compatibility path.
5
+ */
6
+ export declare function scanSpreadsheetPackageInWorker(bytes: ArrayBuffer, signal?: AbortSignal, onFastPathCandidate?: () => void): Promise<SpreadsheetPackageScanResult | null>;
@@ -0,0 +1,49 @@
1
+ import type { CellMatrix } from '@fortune-sheet/core';
2
+ import type { WorkBook } from 'xlsx';
3
+ import type { SpreadsheetImportWorkbookMetadata } from './work-spreadsheet-import-worker-protocol';
4
+ import type { PlainXlsxCellChunk } from './work-xlsx-plain-fast-path';
5
+ import type { XlsxWorksheetXmlScan } from './work-xlsx-worksheet-scan';
6
+ export interface SpreadsheetPackageScanWorkerRequest {
7
+ bytes: ArrayBuffer;
8
+ kind: 'scan';
9
+ }
10
+ export interface SpreadsheetPackageScanResult {
11
+ plainWorksheets: Record<string, SpreadsheetPlainWorksheet> | null;
12
+ workbook: WorkBook | null;
13
+ worksheets: Record<string, XlsxWorksheetXmlScan>;
14
+ }
15
+ export interface SpreadsheetPlainWorksheet {
16
+ columnCount: number;
17
+ data: CellMatrix;
18
+ populatedCellCount: number;
19
+ rowCount: number;
20
+ }
21
+ export type SpreadsheetPackageScanWorkerResponse = {
22
+ kind: 'workbook';
23
+ workbook: SpreadsheetImportWorkbookMetadata;
24
+ } | {
25
+ columnCount: number;
26
+ kind: 'plain-worksheet-start';
27
+ name: string;
28
+ rowCount: number;
29
+ } | {
30
+ columnCount: number;
31
+ dense: true;
32
+ kind: 'worksheet';
33
+ name: string;
34
+ populatedCellCount: number;
35
+ properties: Record<string, unknown>;
36
+ rowCount: number;
37
+ } | {
38
+ chunk: PlainXlsxCellChunk;
39
+ kind: 'plain-cells';
40
+ name: string;
41
+ } | {
42
+ kind: 'fast-path-rejected';
43
+ } | {
44
+ fastPath: boolean;
45
+ kind: 'success';
46
+ worksheets: SpreadsheetPackageScanResult['worksheets'];
47
+ } | {
48
+ kind: 'failure';
49
+ };
@@ -1,3 +1,5 @@
1
1
  import type { OoxmlPackage } from './work-ooxml-package';
2
2
  import type { WorkCompatibilityIssue } from './work-types';
3
- export declare function diagnoseXlsxFormulas(archive: OoxmlPackage): Promise<WorkCompatibilityIssue[]>;
3
+ import { type XlsxFormulaFeatures } from './work-xlsx-formulas';
4
+ import type { XlsxWorksheetXmlScan } from './work-xlsx-worksheet-scan';
5
+ export declare function diagnoseXlsxFormulas(archive: OoxmlPackage, importedFeatures?: XlsxFormulaFeatures | null, worksheetScans?: Readonly<Record<string, XlsxWorksheetXmlScan>>): Promise<WorkCompatibilityIssue[]>;
@@ -2,6 +2,7 @@ import type { Cell } from '@fortune-sheet/core';
2
2
  import type { WorkSheet } from 'xlsx';
3
3
  import { OoxmlPackage } from './work-ooxml-package';
4
4
  import type { WorkSpreadsheetCalculationSettings, WorkSpreadsheetContent, WorkSpreadsheetFormulaMetadata, WorkSpreadsheetFormulaRange, WorkSpreadsheetSheet } from './work-types';
5
+ import type { XlsxWorksheetXmlScan } from './work-xlsx-worksheet-scan';
5
6
  export interface XlsxFormulaCell {
6
7
  address: string;
7
8
  formula: string;
@@ -29,7 +30,7 @@ type XlsxFormulaCellObject = {
29
30
  D?: boolean;
30
31
  };
31
32
  export declare function readXlsxFormulaFeatures(buffer: ArrayBuffer): Promise<XlsxFormulaFeatures>;
32
- export declare function readXlsxFormulaFeaturesFromPackage(archive: OoxmlPackage): Promise<XlsxFormulaFeatures>;
33
+ export declare function readXlsxFormulaFeaturesFromPackage(archive: OoxmlPackage, worksheetScans?: Readonly<Record<string, XlsxWorksheetXmlScan>>): Promise<XlsxFormulaFeatures>;
33
34
  export declare function createSpreadsheetFormulaMetadata(worksheet: WorkSheet, features: XlsxFormulaSheetFeatures | undefined): WorkSpreadsheetFormulaMetadata | undefined;
34
35
  export declare function createXlsxFormulaCell(cell: Cell, row: number, column: number, sheet: WorkSpreadsheetSheet): XlsxFormulaCellObject;
35
36
  export declare function createXlsxErrorCell(cell: Cell): {
@@ -1,12 +1,13 @@
1
1
  import type { Sheet } from '@fortune-sheet/core';
2
2
  import { OoxmlPackage } from './work-ooxml-package';
3
- import { type FortuneConditionalFormatRule } from './work-xlsx-conditional-format';
4
- import { type XlsxProtectionFeatures } from './work-xlsx-protection';
5
- import { type XlsxManualPageBreaks } from './work-xlsx-page-breaks';
3
+ import type { WorkSpreadsheetContent, WorkSpreadsheetDataValidationItem } from './work-types';
6
4
  import { type XlsxWorksheetChart } from './work-xlsx-charts';
5
+ import { type FortuneConditionalFormatRule } from './work-xlsx-conditional-format';
7
6
  import { type XlsxWorksheetImage } from './work-xlsx-images';
7
+ import { type XlsxManualPageBreaks } from './work-xlsx-page-breaks';
8
8
  import { type XlsxPageSetup } from './work-xlsx-page-setup';
9
- import type { WorkSpreadsheetContent, WorkSpreadsheetDataValidationItem } from './work-types';
9
+ import { type XlsxProtectionFeatures } from './work-xlsx-protection';
10
+ import type { XlsxWorksheetXmlScan } from './work-xlsx-worksheet-scan';
10
11
  type FrozenPane = NonNullable<Sheet['frozen']>;
11
12
  export interface XlsxDataValidation {
12
13
  references: string[];
@@ -24,6 +25,6 @@ export interface XlsxSheetFeatures {
24
25
  }
25
26
  export type FortuneDataValidationItem = WorkSpreadsheetDataValidationItem;
26
27
  export declare function readXlsxSheetFeatures(buffer: ArrayBuffer): Promise<Map<string, XlsxSheetFeatures>>;
27
- export declare function readXlsxSheetFeaturesFromPackage(archive: OoxmlPackage): Promise<Map<string, XlsxSheetFeatures>>;
28
+ export declare function readXlsxSheetFeaturesFromPackage(archive: OoxmlPackage, worksheetScans?: Readonly<Record<string, XlsxWorksheetXmlScan>>): Promise<Map<string, XlsxSheetFeatures>>;
28
29
  export declare function patchXlsxSheetFeatures(buffer: ArrayBuffer, content: WorkSpreadsheetContent): Promise<ArrayBuffer>;
29
30
  export {};
@@ -1,3 +1,4 @@
1
1
  import type { OoxmlPackage } from './work-ooxml-package';
2
2
  import type { WorkCompatibilityIssue } from './work-types';
3
- export declare function diagnoseXlsxPivots(archive: OoxmlPackage): Promise<WorkCompatibilityIssue[]>;
3
+ import { type XlsxPivotReadResult } from './work-xlsx-pivots';
4
+ export declare function diagnoseXlsxPivots(archive: OoxmlPackage, importedInspection?: XlsxPivotReadResult | null): Promise<WorkCompatibilityIssue[]>;
@@ -0,0 +1,54 @@
1
+ import type { SpreadsheetImportWorkbookMetadata } from './work-spreadsheet-import-worker-protocol';
2
+ export declare const PLAIN_XLSX_COLUMN_BITS = 14;
3
+ export declare const PLAIN_XLSX_COLUMN_MASK: number;
4
+ export declare const PLAIN_XLSX_CELL_CHUNK_SIZE = 4096;
5
+ export declare const PLAIN_XLSX_ROW_CHUNK_SIZE = 256;
6
+ export declare const PLAIN_XLSX_CELL_NUMBER = 0;
7
+ export declare const PLAIN_XLSX_CELL_BOOLEAN = 1;
8
+ export declare const PLAIN_XLSX_CELL_ERROR = 2;
9
+ export declare const PLAIN_XLSX_CELL_TEXT = 3;
10
+ export interface PlainXlsxPackageParts {
11
+ contentTypes: string;
12
+ packagePaths: readonly string[];
13
+ rootRelationships: string;
14
+ workbook: string;
15
+ workbookRelationships: string;
16
+ }
17
+ export interface PlainXlsxWorkbookSheet {
18
+ name: string;
19
+ partPath: string;
20
+ }
21
+ export interface PlainXlsxWorkbookPlan {
22
+ sheets: PlainXlsxWorkbookSheet[];
23
+ workbook: SpreadsheetImportWorkbookMetadata;
24
+ }
25
+ export interface PlainXlsxCellChunk {
26
+ coordinates: Uint32Array;
27
+ kinds: Uint8Array;
28
+ numericValues: Float64Array;
29
+ startRow: number;
30
+ textValues: string[];
31
+ }
32
+ export interface PlainXlsxWorksheetResult {
33
+ columnCount: number;
34
+ populatedCellCount: number;
35
+ properties: Record<string, unknown>;
36
+ rowCount: number;
37
+ }
38
+ export interface PlainXlsxRangeExtent {
39
+ columnCount: number;
40
+ rowCount: number;
41
+ }
42
+ /**
43
+ * Authenticates the deliberately small OOXML subset handled by the fast
44
+ * worksheet parser. Any package part or workbook construct outside this
45
+ * closed set returns null and leaves SheetJS as the authority.
46
+ */
47
+ export declare function createPlainXlsxWorkbookPlan(parts: PlainXlsxPackageParts): PlainXlsxWorkbookPlan | null;
48
+ /**
49
+ * Parses primitive dense cells with a low-allocation cursor. Row chunks may be
50
+ * emitted provisionally; callers must use them only when the final result is
51
+ * non-null because a later unsupported element invalidates the whole sheet.
52
+ */
53
+ export declare function streamPlainXlsxWorksheet(source: string, visit: (chunk: PlainXlsxCellChunk) => void, start?: (extent: PlainXlsxRangeExtent) => void): PlainXlsxWorksheetResult | null;
54
+ export declare function plainXlsxRangeExtent(reference: string): PlainXlsxRangeExtent | null;
@@ -0,0 +1 @@
1
+ export declare function xlsxWorksheetRequiresSheetJsCellStyles(source: string): boolean;
@@ -0,0 +1,12 @@
1
+ export interface XlsxWorksheetXmlScan {
2
+ hasDiagnosticFeatures: boolean;
3
+ hasFormulaFeatures: boolean;
4
+ hasImportedFeatures: boolean;
5
+ requiresSheetJsCellStyles: boolean;
6
+ }
7
+ /**
8
+ * Builds every worksheet gate in one pass over the decompressed XML. The
9
+ * scanner deliberately permits false positives because they only select the
10
+ * existing full parser path; a false negative could discard workbook state.
11
+ */
12
+ export declare function scanXlsxWorksheetXml(source: string): XlsxWorksheetXmlScan;
@@ -0,0 +1,12 @@
1
+ import type { CellObject, WorkSheet } from 'xlsx';
2
+ export interface XlsxWorksheetCellEntry {
3
+ address: string;
4
+ cell: CellObject;
5
+ column: number;
6
+ row: number;
7
+ }
8
+ /**
9
+ * Iterates both SheetJS sparse address maps and dense row arrays without
10
+ * materializing a second list of every worksheet cell.
11
+ */
12
+ export declare function xlsxWorksheetCellEntries(worksheet: WorkSheet): Generator<XlsxWorksheetCellEntry>;
Binary file
@@ -13051,8 +13051,8 @@
13051
13051
  };
13052
13052
  })();
13053
13053
  (()=>{
13054
- const MAX_LAYOUT_BLOCKS = 10000;
13055
- const MAX_LAYOUT_PAGE_STYLES = MAX_LAYOUT_BLOCKS;
13054
+ const MAX_LAYOUT_BLOCKS = 200000;
13055
+ const MAX_LAYOUT_PAGE_STYLES = 10000;
13056
13056
  const MAX_LAYOUT_EXTENT = 1000000;
13057
13057
  const MAX_LAYOUT_PAGE_INDEX = 1000000;
13058
13058
  function layoutOfficeDocumentInJavaScript(request) {
@@ -13072,10 +13072,10 @@
13072
13072
  ensurePageMetrics(pages, page);
13073
13073
  if (void 0 !== block.flowCount) {
13074
13074
  const end = index + block.flowCount;
13075
- layoutFlow(request.blocks.slice(index, end), request.blocks.slice(end), pages, page, request.page, pageStyles, end < request.blocks.length);
13075
+ layoutFlow(request.blocks, index, end, pages, page, request.page, pageStyles, end < request.blocks.length);
13076
13076
  index = end;
13077
13077
  } else {
13078
- layoutSingleBlock(block, request.blocks.slice(index + 1), pages, page, request.page, pageStyles, index + 1 < request.blocks.length);
13078
+ layoutSingleBlock(block, request.blocks, index + 1, pages, page, request.page, pageStyles, index + 1 < request.blocks.length);
13079
13079
  index += 1;
13080
13080
  }
13081
13081
  }
@@ -13119,7 +13119,7 @@
13119
13119
  }
13120
13120
  validateFlowSequences(request.blocks);
13121
13121
  }
13122
- function layoutSingleBlock(block, next, pages, page, defaultPage, pageStyles, hasMoreBlocks) {
13122
+ function layoutSingleBlock(block, blocks, nextIndex, pages, page, defaultPage, pageStyles, hasMoreBlocks) {
13123
13123
  const availableHeight = pageBodyHeight(page);
13124
13124
  let current = pages.at(-1);
13125
13125
  let currentHasContent = current.placements.length > 0;
@@ -13129,7 +13129,7 @@
13129
13129
  currentHasContent = false;
13130
13130
  }
13131
13131
  const remaining = Math.max(0, availableHeight - current.usedHeight);
13132
- const nextHeight = nextBlockPreviewHeight(next, page, defaultPage, pageStyles);
13132
+ const nextHeight = nextBlockPreviewHeight(blocks, nextIndex, page, defaultPage, pageStyles);
13133
13133
  const groupedHeight = block.height + (block.keepWithNext ? nextHeight : 0);
13134
13134
  const shouldAdvance = currentHasContent && (block.height > remaining || (block.keepTogether || block.keepWithNext) && groupedHeight <= availableHeight && groupedHeight > remaining);
13135
13135
  if (shouldAdvance) {
@@ -13139,13 +13139,13 @@
13139
13139
  placeFragment(block, current, availableHeight);
13140
13140
  if (block.breakAfter && hasMoreBlocks) pages.push(emptyPage(nextPageIndex(pages), page));
13141
13141
  }
13142
- function layoutFlow(blocks, next, pages, page, defaultPage, pageStyles, hasMoreBlocks) {
13142
+ function layoutFlow(blocks, start, end, pages, page, defaultPage, pageStyles, hasMoreBlocks) {
13143
13143
  const availableHeight = pageBodyHeight(page);
13144
- const first = blocks[0];
13145
- const last = blocks.at(-1);
13144
+ const first = blocks[start];
13145
+ const last = blocks[end - 1];
13146
13146
  if (first.breakBefore && pages.at(-1)?.placements.length) pages.push(emptyPage(nextPageIndex(pages), page));
13147
- const totalHeight = fragmentHeight(blocks, 0, blocks.length);
13148
- const nextHeight = last.keepWithNext ? nextBlockPreviewHeight(next, page, defaultPage, pageStyles) : 0;
13147
+ const totalHeight = fragmentHeight(blocks, start, end);
13148
+ const nextHeight = last.keepWithNext ? nextBlockPreviewHeight(blocks, end, page, defaultPage, pageStyles) : 0;
13149
13149
  let current = pages.at(-1);
13150
13150
  const repeatHeaderCount = first.repeatHeaderCount ?? 0;
13151
13151
  const repeatHeaderHeight = first.repeatHeaderHeight ?? 0;
@@ -13154,8 +13154,8 @@
13154
13154
  current = emptyPage(nextPageIndex(pages), page);
13155
13155
  pages.push(current);
13156
13156
  }
13157
- if (repeatHeaderCount > 0 && repeatHeaderCount < blocks.length) {
13158
- const leadingHeight = fragmentHeight(blocks, 0, repeatHeaderCount + 1);
13157
+ if (repeatHeaderCount > 0 && repeatHeaderCount < end - start) {
13158
+ const leadingHeight = fragmentHeight(blocks, start, start + repeatHeaderCount + 1);
13159
13159
  const remainingHeight = Math.max(0, availableHeight - current.usedHeight);
13160
13160
  if (current.placements.length > 0 && leadingHeight <= availableHeight && leadingHeight > remainingHeight) {
13161
13161
  current = emptyPage(nextPageIndex(pages), page);
@@ -13163,22 +13163,23 @@
13163
13163
  }
13164
13164
  }
13165
13165
  const minimum = Math.max(1, first.minimumFragmentsPerPage ?? 1);
13166
- let cursor = 0;
13167
- while(cursor < blocks.length){
13166
+ let cursor = start;
13167
+ let remainingFlowHeight = totalHeight;
13168
+ while(cursor < end){
13168
13169
  current = pages.at(-1);
13169
- if (cursor >= repeatHeaderCount && cursor > 0 && repeatHeaderHeight > 0 && 0 === current.placements.length && 0 === current.usedHeight) current.usedHeight = repeatHeaderHeight;
13170
+ if (cursor - start >= repeatHeaderCount && cursor > start && repeatHeaderHeight > 0 && 0 === current.placements.length && 0 === current.usedHeight) current.usedHeight = repeatHeaderHeight;
13170
13171
  const currentHasContent = current.placements.length > 0;
13171
13172
  const remainingHeight = Math.max(0, availableHeight - current.usedHeight);
13172
- const remainingFragments = blocks.length - cursor;
13173
- const remainingFlowHeight = fragmentHeight(blocks, cursor, blocks.length);
13173
+ const remainingFragments = end - cursor;
13174
13174
  if (nextHeight > 0 && currentHasContent && remainingFlowHeight <= remainingHeight && remainingFlowHeight + nextHeight > remainingHeight && remainingFlowHeight + nextHeight <= availableHeight) {
13175
13175
  pages.push(emptyPage(nextPageIndex(pages), page));
13176
13176
  continue;
13177
13177
  }
13178
- let fitting = fragmentsFitting(blocks, cursor, blocks.length, remainingHeight);
13178
+ let fitting = fragmentsFitting(blocks, cursor, end, remainingHeight);
13179
13179
  if (fitting === remainingFragments) {
13180
- placeFragments(blocks, cursor, blocks.length, current, availableHeight);
13181
- cursor = blocks.length;
13180
+ placeFragments(blocks, cursor, end, current, availableHeight);
13181
+ cursor = end;
13182
+ remainingFlowHeight = 0;
13182
13183
  continue;
13183
13184
  }
13184
13185
  if (0 === fitting) {
@@ -13195,18 +13196,19 @@
13195
13196
  continue;
13196
13197
  }
13197
13198
  fitting = Math.max(1, fitting);
13199
+ remainingFlowHeight -= fragmentHeight(blocks, cursor, cursor + fitting);
13198
13200
  placeFragments(blocks, cursor, cursor + fitting, current, availableHeight);
13199
13201
  cursor += fitting;
13200
- if (cursor < blocks.length) pages.push(emptyPage(nextPageIndex(pages), page));
13202
+ if (cursor < end) pages.push(emptyPage(nextPageIndex(pages), page));
13201
13203
  }
13202
13204
  if (last.breakAfter && hasMoreBlocks) pages.push(emptyPage(nextPageIndex(pages), page));
13203
13205
  }
13204
- function nextBlockPreviewHeight(blocks, currentPage, defaultPage, pageStyles) {
13205
- const first = blocks[0];
13206
+ function nextBlockPreviewHeight(blocks, start, currentPage, defaultPage, pageStyles) {
13207
+ const first = blocks[start];
13206
13208
  if (!first || first.breakBefore) return 0;
13207
13209
  if (!pageMetricsEqual(currentPage, pageMetricsForBlock(first, defaultPage, pageStyles))) return 0;
13208
13210
  const count = Math.min(2, first.flowCount ?? 1);
13209
- return fragmentHeight(blocks, 0, count);
13211
+ return fragmentHeight(blocks, start, Math.min(blocks.length, start + count));
13210
13212
  }
13211
13213
  function fragmentsFitting(blocks, start, end, availableHeight) {
13212
13214
  let used = 0;
@@ -13274,13 +13276,13 @@
13274
13276
  const count = block.flowCount;
13275
13277
  const repeatHeaderCount = block.repeatHeaderCount;
13276
13278
  const repeatHeaderHeight = block.repeatHeaderHeight;
13277
- const flow = blocks.slice(index, index + count);
13278
- if (flow.length !== count) throw kernelError('office.kernel.flow_sequence_invalid', 'A layout flow must contain its declared number of fragments.');
13279
- flow.forEach((fragment, flowIndex)=>{
13279
+ if (index + count > blocks.length) throw kernelError('office.kernel.flow_sequence_invalid', 'A layout flow must contain its declared number of fragments.');
13280
+ for(let flowIndex = 0; flowIndex < count; flowIndex += 1){
13281
+ const fragment = blocks[index + flowIndex];
13280
13282
  if (fragment.flowId !== block.flowId || fragment.flowIndex !== flowIndex || fragment.flowCount !== count || fragment.minimumFragmentsPerPage !== block.minimumFragmentsPerPage || fragment.repeatHeaderCount !== repeatHeaderCount || fragment.repeatHeaderHeight !== repeatHeaderHeight || fragment.pageStyleId !== block.pageStyleId) throw kernelError('office.kernel.flow_sequence_invalid', 'Layout flow fragments must be consecutive and consistently indexed.');
13281
13283
  if (flowIndex > 0 && fragment.breakBefore) throw kernelError('office.kernel.flow_break_invalid', 'Only the first flow fragment may request breakBefore.');
13282
13284
  if (flowIndex + 1 < count && fragment.breakAfter) throw kernelError('office.kernel.flow_break_invalid', 'Only the last flow fragment may request breakAfter.');
13283
- });
13285
+ }
13284
13286
  index += count;
13285
13287
  }
13286
13288
  }
package/dist/react.d.ts CHANGED
@@ -8,13 +8,19 @@ import type { SpreadsheetEditorProps as InternalSpreadsheetEditorProps } from '.
8
8
  import type { WorkOfficeFileAction } from './internal/features/work/editors/work-office-chrome';
9
9
  import { type OfficeSurfaceProps, type OfficeTheme } from './office-surface';
10
10
  export type OfficeEditorKind = 'document' | 'markdown' | 'spreadsheet' | 'presentation' | 'pdf';
11
+ export interface OfficeEditorPreloadOptions {
12
+ /** Overrides the packaged PDFium asset when preloading the PDF runtime. */
13
+ pdfWasmUrl?: string;
14
+ /** Also fetches PDFium WebAssembly. Disabled unless explicitly enabled. */
15
+ preloadRuntimeAssets?: boolean;
16
+ }
11
17
  /**
12
18
  * Starts loading one editor without mounting it.
13
19
  *
14
20
  * Call this from an intent signal such as hover or keyboard focus to keep the
15
21
  * initial application bundle small without adding latency to editor opening.
16
22
  */
17
- export declare function preloadOfficeEditor(kind: OfficeEditorKind): Promise<void>;
23
+ export declare function preloadOfficeEditor(kind: OfficeEditorKind, options?: OfficeEditorPreloadOptions): Promise<void>;
18
24
  export declare const defaultPdfiumWasmUrl: string;
19
25
  export declare const defaultOfficeKernelWasmUrl: string;
20
26
  export declare const defaultDocumentLayoutFontUrl: string;