@beyondwork/docx-react-component 1.0.129 → 1.0.130
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.
- package/dist/api/public-types.cjs +595 -18
- package/dist/api/public-types.d.cts +1 -1
- package/dist/api/public-types.d.ts +1 -1
- package/dist/api/public-types.js +4 -4
- package/dist/api/v3.cjs +1164 -332
- package/dist/api/v3.d.cts +2 -2
- package/dist/api/v3.d.ts +2 -2
- package/dist/api/v3.js +13 -13
- package/dist/{chunk-OTQIW2TC.js → chunk-35RHOE6I.js} +105 -4
- package/dist/{chunk-PGKUJZXV.js → chunk-3YCQM2RV.js} +6 -6
- package/dist/{chunk-JJGVE5J7.js → chunk-4YCWECLZ.js} +1 -1
- package/dist/{chunk-EZKJXIPH.js → chunk-6TBLDBCL.js} +1 -1
- package/dist/{chunk-SKPTKQHF.js → chunk-7G5GR3VV.js} +122 -23
- package/dist/{chunk-HUIHBBAQ.js → chunk-A3GSNB4G.js} +17 -6
- package/dist/{chunk-5DGKFNQT.js → chunk-A66ZVUAT.js} +150 -1
- package/dist/{chunk-YIYM4ZAP.js → chunk-CI2TD3T4.js} +1 -1
- package/dist/{chunk-63FYIGCT.js → chunk-DGA7M77X.js} +2 -2
- package/dist/{chunk-EB6M3GE6.js → chunk-FM4K4XFJ.js} +100 -97
- package/dist/{chunk-VNLDQJ47.js → chunk-HYHCRMR7.js} +1 -1
- package/dist/{chunk-DJU2W4E4.js → chunk-KNHMXKC6.js} +2 -2
- package/dist/{chunk-Q3QYGKFE.js → chunk-M7YRJX6V.js} +10 -21
- package/dist/{chunk-KFCQYZXR.js → chunk-OVLZQ6FZ.js} +61 -0
- package/dist/{chunk-W34X3KBR.js → chunk-PHMWH23E.js} +1 -1
- package/dist/{chunk-DDN2AIGE.js → chunk-Q7Y57KOK.js} +2 -2
- package/dist/{chunk-LJH64PV3.js → chunk-QXKQPUOM.js} +3 -3
- package/dist/{chunk-CX42VC67.js → chunk-SYQWQ6FE.js} +1 -1
- package/dist/{chunk-5DSHUYSY.js → chunk-T5YYFDZB.js} +1 -1
- package/dist/{chunk-RMRTQGW3.js → chunk-THVM6EP5.js} +371 -13
- package/dist/{chunk-XMHSGPLN.js → chunk-VRKK2CSZ.js} +111 -90
- package/dist/{chunk-OL2UEHRP.js → chunk-WUDSNHWF.js} +1 -1
- package/dist/{chunk-XQCAMKIQ.js → chunk-WZDKNF37.js} +250 -106
- package/dist/{chunk-PRAZBHNF.js → chunk-YLL7MF5C.js} +15 -15
- package/dist/{chunk-YZDZ4FGR.js → chunk-ZVC23LKV.js} +1 -1
- package/dist/compare.cjs +100 -97
- package/dist/compare.js +3 -3
- package/dist/core/commands/formatting-commands.d.cts +1 -1
- package/dist/core/commands/formatting-commands.d.ts +1 -1
- package/dist/core/commands/image-commands.cjs +16 -5
- package/dist/core/commands/image-commands.d.cts +1 -1
- package/dist/core/commands/image-commands.d.ts +1 -1
- package/dist/core/commands/image-commands.js +5 -5
- package/dist/core/commands/section-layout-commands.d.cts +1 -1
- package/dist/core/commands/section-layout-commands.d.ts +1 -1
- package/dist/core/commands/style-commands.d.cts +1 -1
- package/dist/core/commands/style-commands.d.ts +1 -1
- package/dist/core/commands/table-structure-commands.cjs +16 -5
- package/dist/core/commands/table-structure-commands.d.cts +1 -1
- package/dist/core/commands/table-structure-commands.d.ts +1 -1
- package/dist/core/commands/table-structure-commands.js +4 -4
- package/dist/core/commands/text-commands.cjs +16 -5
- package/dist/core/commands/text-commands.d.cts +1 -1
- package/dist/core/commands/text-commands.d.ts +1 -1
- package/dist/core/commands/text-commands.js +5 -5
- package/dist/core/selection/mapping.d.cts +1 -1
- package/dist/core/selection/mapping.d.ts +1 -1
- package/dist/core/state/editor-state.d.cts +1 -1
- package/dist/core/state/editor-state.d.ts +1 -1
- package/dist/index.cjs +1280 -347
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +24 -24
- package/dist/io/docx-session.cjs +216 -203
- package/dist/io/docx-session.d.cts +3 -3
- package/dist/io/docx-session.d.ts +3 -3
- package/dist/io/docx-session.js +6 -6
- package/dist/legal.cjs +9 -20
- package/dist/legal.js +3 -3
- package/dist/{loader-4qsw4eIU.d.ts → loader-B-aL5HGD.d.ts} +2 -2
- package/dist/{loader-B8TKhmQi.d.cts → loader-DiY_ZgKl.d.cts} +2 -2
- package/dist/{measurement-backend-canvas-Q3MJMEYX.js → measurement-backend-canvas-F7ZYDACK.js} +1 -1
- package/dist/{public-types-p9b8rfy8.d.ts → public-types-DyqnxxO9.d.ts} +124 -1
- package/dist/{public-types-B5CRoR6f.d.cts → public-types-gvubspUI.d.cts} +124 -1
- package/dist/public-types.cjs +595 -18
- package/dist/public-types.d.cts +1 -1
- package/dist/public-types.d.ts +1 -1
- package/dist/public-types.js +4 -4
- package/dist/runtime/collab.d.cts +2 -2
- package/dist/runtime/collab.d.ts +2 -2
- package/dist/runtime/document-runtime.cjs +908 -129
- package/dist/runtime/document-runtime.d.cts +1 -1
- package/dist/runtime/document-runtime.d.ts +1 -1
- package/dist/runtime/document-runtime.js +17 -17
- package/dist/{session-BnGIjaex.d.cts → session-BUN6B-Vj.d.cts} +2 -2
- package/dist/{session-vEYKf-w3.d.ts → session-CDB0hohT.d.ts} +2 -2
- package/dist/session.cjs +216 -203
- package/dist/session.d.cts +4 -4
- package/dist/session.d.ts +4 -4
- package/dist/session.js +7 -7
- package/dist/tailwind.cjs +595 -18
- package/dist/tailwind.d.cts +1 -1
- package/dist/tailwind.d.ts +1 -1
- package/dist/tailwind.js +8 -8
- package/dist/{types-BLuvZ6cQ.d.cts → types-C4bz3kDU.d.cts} +1 -1
- package/dist/{types-Dutlyj0T.d.ts → types-VWH6CRvG.d.ts} +1 -1
- package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
- package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
- package/dist/ui-tailwind/editor-surface/search-plugin.js +5 -5
- package/dist/ui-tailwind.cjs +595 -18
- package/dist/ui-tailwind.d.cts +2 -2
- package/dist/ui-tailwind.d.ts +2 -2
- package/dist/ui-tailwind.js +8 -8
- package/package.json +1 -1
|
@@ -2,11 +2,12 @@ import {
|
|
|
2
2
|
buildRunFormattingMap,
|
|
3
3
|
calculateParagraphHeight,
|
|
4
4
|
createEmpiricalBackend,
|
|
5
|
+
createLayoutReadyFormattingSnapshot,
|
|
5
6
|
resolveBlockFormatting,
|
|
6
7
|
resolveCharsPerLine,
|
|
7
8
|
resolveNumberingPrefixLength,
|
|
8
9
|
resolveTextWidth
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OVLZQ6FZ.js";
|
|
10
11
|
import {
|
|
11
12
|
parseTextStory
|
|
12
13
|
} from "./chunk-QIO6V46H.js";
|
|
@@ -18,13 +19,13 @@ import {
|
|
|
18
19
|
resolveSectionVariants,
|
|
19
20
|
sectionSupportsStoryTarget,
|
|
20
21
|
storyTargetKey
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-A3GSNB4G.js";
|
|
22
23
|
import {
|
|
23
24
|
createSelectionSnapshot
|
|
24
25
|
} from "./chunk-OYGMRRR7.js";
|
|
25
26
|
import {
|
|
26
27
|
collectCanonicalLayoutInputs
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-A66ZVUAT.js";
|
|
28
29
|
import {
|
|
29
30
|
MAIN_STORY_TARGET,
|
|
30
31
|
createDetachedAnchor,
|
|
@@ -6582,20 +6583,337 @@ function createEmpiricalProvider() {
|
|
|
6582
6583
|
}
|
|
6583
6584
|
async function createCanvasProvider(fontLoader) {
|
|
6584
6585
|
try {
|
|
6585
|
-
const mod = await import("./measurement-backend-canvas-
|
|
6586
|
+
const mod = await import("./measurement-backend-canvas-F7ZYDACK.js");
|
|
6586
6587
|
return mod.createCanvasBackend(fontLoader);
|
|
6587
6588
|
} catch {
|
|
6588
6589
|
return createEmpiricalProvider();
|
|
6589
6590
|
}
|
|
6590
6591
|
}
|
|
6591
6592
|
|
|
6593
|
+
// src/runtime/layout/persistent-layout-measurement-cache.ts
|
|
6594
|
+
var DEFAULT_MAX_ENTRIES = 1e4;
|
|
6595
|
+
var DEFAULT_MAX_ESTIMATED_BYTES = 50 * 1024 * 1024;
|
|
6596
|
+
function createPersistentLayoutMeasurementCache(options = {}) {
|
|
6597
|
+
const maxEntries = Math.max(1, options.maxEntries ?? DEFAULT_MAX_ENTRIES);
|
|
6598
|
+
const maxEstimatedBytes = Math.max(
|
|
6599
|
+
1024,
|
|
6600
|
+
options.maxEstimatedBytes ?? DEFAULT_MAX_ESTIMATED_BYTES
|
|
6601
|
+
);
|
|
6602
|
+
const entries = /* @__PURE__ */ new Map();
|
|
6603
|
+
const counters = {
|
|
6604
|
+
hits: 0,
|
|
6605
|
+
misses: 0,
|
|
6606
|
+
sets: 0,
|
|
6607
|
+
evictions: 0,
|
|
6608
|
+
clears: 0,
|
|
6609
|
+
estimatedBytes: 0,
|
|
6610
|
+
invalidatedByReason: {}
|
|
6611
|
+
};
|
|
6612
|
+
function evictOldest() {
|
|
6613
|
+
const oldest = entries.keys().next();
|
|
6614
|
+
if (oldest.done) return;
|
|
6615
|
+
const entry = entries.get(oldest.value);
|
|
6616
|
+
if (entry) {
|
|
6617
|
+
counters.estimatedBytes -= entry.estimatedBytes;
|
|
6618
|
+
}
|
|
6619
|
+
entries.delete(oldest.value);
|
|
6620
|
+
counters.evictions += 1;
|
|
6621
|
+
}
|
|
6622
|
+
return {
|
|
6623
|
+
get(key) {
|
|
6624
|
+
const cacheKey = serializeCacheKey(key);
|
|
6625
|
+
const entry = entries.get(cacheKey);
|
|
6626
|
+
if (!entry) {
|
|
6627
|
+
counters.misses += 1;
|
|
6628
|
+
return void 0;
|
|
6629
|
+
}
|
|
6630
|
+
entries.delete(cacheKey);
|
|
6631
|
+
entries.set(cacheKey, entry);
|
|
6632
|
+
counters.hits += 1;
|
|
6633
|
+
return entry.value;
|
|
6634
|
+
},
|
|
6635
|
+
set(key, value) {
|
|
6636
|
+
const cacheKey = serializeCacheKey(key);
|
|
6637
|
+
const previous = entries.get(cacheKey);
|
|
6638
|
+
if (previous) {
|
|
6639
|
+
counters.estimatedBytes -= previous.estimatedBytes;
|
|
6640
|
+
entries.delete(cacheKey);
|
|
6641
|
+
}
|
|
6642
|
+
const estimatedBytes = estimateBytes(key, value);
|
|
6643
|
+
entries.set(cacheKey, { key, value, estimatedBytes });
|
|
6644
|
+
counters.estimatedBytes += estimatedBytes;
|
|
6645
|
+
counters.sets += 1;
|
|
6646
|
+
while (entries.size > maxEntries || counters.estimatedBytes > maxEstimatedBytes) {
|
|
6647
|
+
evictOldest();
|
|
6648
|
+
}
|
|
6649
|
+
},
|
|
6650
|
+
invalidate(reason, predicate) {
|
|
6651
|
+
if (!predicate) {
|
|
6652
|
+
const removed2 = entries.size;
|
|
6653
|
+
counters.estimatedBytes = 0;
|
|
6654
|
+
entries.clear();
|
|
6655
|
+
counters.invalidatedByReason[reason] = (counters.invalidatedByReason[reason] ?? 0) + removed2;
|
|
6656
|
+
return;
|
|
6657
|
+
}
|
|
6658
|
+
let removed = 0;
|
|
6659
|
+
for (const [cacheKey, entry] of entries) {
|
|
6660
|
+
if (!predicate(entry.key)) continue;
|
|
6661
|
+
counters.estimatedBytes -= entry.estimatedBytes;
|
|
6662
|
+
entries.delete(cacheKey);
|
|
6663
|
+
removed += 1;
|
|
6664
|
+
}
|
|
6665
|
+
counters.invalidatedByReason[reason] = (counters.invalidatedByReason[reason] ?? 0) + removed;
|
|
6666
|
+
},
|
|
6667
|
+
clear(reason) {
|
|
6668
|
+
const removed = entries.size;
|
|
6669
|
+
counters.estimatedBytes = 0;
|
|
6670
|
+
entries.clear();
|
|
6671
|
+
counters.clears += 1;
|
|
6672
|
+
counters.invalidatedByReason[reason] = (counters.invalidatedByReason[reason] ?? 0) + removed;
|
|
6673
|
+
},
|
|
6674
|
+
stats() {
|
|
6675
|
+
return {
|
|
6676
|
+
hits: counters.hits,
|
|
6677
|
+
misses: counters.misses,
|
|
6678
|
+
sets: counters.sets,
|
|
6679
|
+
evictions: counters.evictions,
|
|
6680
|
+
clears: counters.clears,
|
|
6681
|
+
size: entries.size,
|
|
6682
|
+
estimatedBytes: Math.max(0, counters.estimatedBytes),
|
|
6683
|
+
invalidatedByReason: { ...counters.invalidatedByReason }
|
|
6684
|
+
};
|
|
6685
|
+
}
|
|
6686
|
+
};
|
|
6687
|
+
}
|
|
6688
|
+
function createCachedLayoutMeasurementProvider(delegate, options = {}) {
|
|
6689
|
+
const cache = options.cache ?? createPersistentLayoutMeasurementCache(options);
|
|
6690
|
+
function emitCounter(type, key) {
|
|
6691
|
+
const telemetryBus = options.telemetryBus;
|
|
6692
|
+
if (!telemetryBus?.isEnabled("layout")) return;
|
|
6693
|
+
telemetryBus.emitLazy("layout", () => ({
|
|
6694
|
+
type,
|
|
6695
|
+
payload: key ? {
|
|
6696
|
+
measurementKind: key.measurementKind,
|
|
6697
|
+
blockId: key.blockId,
|
|
6698
|
+
backendVersion: key.backendVersion
|
|
6699
|
+
} : void 0
|
|
6700
|
+
}));
|
|
6701
|
+
}
|
|
6702
|
+
return {
|
|
6703
|
+
get fidelity() {
|
|
6704
|
+
return delegate.fidelity;
|
|
6705
|
+
},
|
|
6706
|
+
measurementCache: cache,
|
|
6707
|
+
measurementCacheStats() {
|
|
6708
|
+
return cache.stats();
|
|
6709
|
+
},
|
|
6710
|
+
whenReady() {
|
|
6711
|
+
return delegate.whenReady();
|
|
6712
|
+
},
|
|
6713
|
+
measureLineFragments(input) {
|
|
6714
|
+
const key = buildLineFragmentsKey(input, delegate, options);
|
|
6715
|
+
const cached = cache.get(key);
|
|
6716
|
+
if (cached) {
|
|
6717
|
+
emitCounter("pageRender.measurement.hit", key);
|
|
6718
|
+
return cloneMeasuredLineFragments(cached);
|
|
6719
|
+
}
|
|
6720
|
+
emitCounter("pageRender.measurement.miss", key);
|
|
6721
|
+
const measured = delegate.measureLineFragments(input);
|
|
6722
|
+
cache.set(key, cloneMeasuredLineFragments(measured));
|
|
6723
|
+
return measured;
|
|
6724
|
+
},
|
|
6725
|
+
measureInlineObject(input) {
|
|
6726
|
+
const key = buildInlineObjectKey(input, delegate, options);
|
|
6727
|
+
const cached = cache.get(key);
|
|
6728
|
+
if (cached) {
|
|
6729
|
+
emitCounter("pageRender.measurement.hit", key);
|
|
6730
|
+
return { ...cached };
|
|
6731
|
+
}
|
|
6732
|
+
emitCounter("pageRender.measurement.miss", key);
|
|
6733
|
+
const measured = delegate.measureInlineObject(input);
|
|
6734
|
+
cache.set(key, { ...measured });
|
|
6735
|
+
return measured;
|
|
6736
|
+
},
|
|
6737
|
+
measureTableBlock(input) {
|
|
6738
|
+
const key = buildTableBlockKey(input, delegate, options);
|
|
6739
|
+
const cached = cache.get(key);
|
|
6740
|
+
if (cached) {
|
|
6741
|
+
emitCounter("pageRender.measurement.hit", key);
|
|
6742
|
+
return cloneMeasuredTableBlock(cached);
|
|
6743
|
+
}
|
|
6744
|
+
emitCounter("pageRender.measurement.miss", key);
|
|
6745
|
+
const measured = delegate.measureTableBlock(input);
|
|
6746
|
+
cache.set(key, cloneMeasuredTableBlock(measured));
|
|
6747
|
+
return measured;
|
|
6748
|
+
},
|
|
6749
|
+
invalidateCache() {
|
|
6750
|
+
delegate.invalidateCache();
|
|
6751
|
+
cache.clear("provider.invalidateCache");
|
|
6752
|
+
emitCounter("pageRender.measurement.invalidated.provider.invalidateCache");
|
|
6753
|
+
}
|
|
6754
|
+
};
|
|
6755
|
+
}
|
|
6756
|
+
function isCachedLayoutMeasurementProvider(provider) {
|
|
6757
|
+
return typeof provider.measurementCacheStats === "function";
|
|
6758
|
+
}
|
|
6759
|
+
function buildLineFragmentsKey(input, delegate, options) {
|
|
6760
|
+
const block = input.block;
|
|
6761
|
+
const identity = measurementIdentityForBlock(block);
|
|
6762
|
+
return {
|
|
6763
|
+
measurementKind: "line-fragments",
|
|
6764
|
+
blockId: identity.blockId,
|
|
6765
|
+
blockPath: identity.blockPath,
|
|
6766
|
+
contentHash: hashStable({
|
|
6767
|
+
kind: block.kind,
|
|
6768
|
+
identity: identity.identityHash,
|
|
6769
|
+
segments: block.segments,
|
|
6770
|
+
numbering: block.numbering,
|
|
6771
|
+
numberingPrefix: block.numberingPrefix,
|
|
6772
|
+
numberingSuffix: block.numberingSuffix,
|
|
6773
|
+
resolvedNumbering: block.resolvedNumbering
|
|
6774
|
+
}),
|
|
6775
|
+
formattingHash: createLayoutReadyFormattingSnapshot(
|
|
6776
|
+
input.formatting,
|
|
6777
|
+
input.runs
|
|
6778
|
+
).hash,
|
|
6779
|
+
constraintsHash: hashStable({ columnWidth: input.columnWidth }),
|
|
6780
|
+
sectionHash: resolveOptionValue(options.sectionHash, "section:provider-input"),
|
|
6781
|
+
fontEpoch: resolveOptionValue(options.fontEpoch, "font:default"),
|
|
6782
|
+
backendVersion: resolveOptionValue(options.backendVersion, delegate.fidelity),
|
|
6783
|
+
displayModeHash: resolveOptionValue(options.displayModeHash, "display:default")
|
|
6784
|
+
};
|
|
6785
|
+
}
|
|
6786
|
+
function buildInlineObjectKey(input, delegate, options) {
|
|
6787
|
+
return {
|
|
6788
|
+
measurementKind: "inline-object",
|
|
6789
|
+
blockId: "inline-object",
|
|
6790
|
+
blockPath: "inline-object",
|
|
6791
|
+
contentHash: hashStable({ display: input.display }),
|
|
6792
|
+
formattingHash: "format:none",
|
|
6793
|
+
constraintsHash: hashStable({
|
|
6794
|
+
widthTwips: input.widthTwips,
|
|
6795
|
+
heightTwips: input.heightTwips
|
|
6796
|
+
}),
|
|
6797
|
+
sectionHash: resolveOptionValue(options.sectionHash, "section:provider-input"),
|
|
6798
|
+
fontEpoch: resolveOptionValue(options.fontEpoch, "font:default"),
|
|
6799
|
+
backendVersion: resolveOptionValue(options.backendVersion, delegate.fidelity),
|
|
6800
|
+
displayModeHash: resolveOptionValue(options.displayModeHash, "display:default")
|
|
6801
|
+
};
|
|
6802
|
+
}
|
|
6803
|
+
function buildTableBlockKey(input, delegate, options) {
|
|
6804
|
+
const block = input.block;
|
|
6805
|
+
const identity = measurementIdentityForBlock(block);
|
|
6806
|
+
return {
|
|
6807
|
+
measurementKind: "table-block",
|
|
6808
|
+
blockId: identity.blockId,
|
|
6809
|
+
blockPath: identity.blockPath,
|
|
6810
|
+
contentHash: hashStable({
|
|
6811
|
+
kind: block.kind,
|
|
6812
|
+
identity: identity.identityHash,
|
|
6813
|
+
rows: block.rows,
|
|
6814
|
+
gridColumns: block.gridColumns,
|
|
6815
|
+
gridColumnsRelative: block.gridColumnsRelative,
|
|
6816
|
+
tableResolved: block.tableResolved,
|
|
6817
|
+
tblLook: block.tblLook
|
|
6818
|
+
}),
|
|
6819
|
+
formattingHash: hashStable({
|
|
6820
|
+
styleId: block.styleId,
|
|
6821
|
+
alignment: block.alignment
|
|
6822
|
+
}),
|
|
6823
|
+
constraintsHash: hashStable({ columnWidth: input.columnWidth }),
|
|
6824
|
+
sectionHash: resolveOptionValue(options.sectionHash, "section:provider-input"),
|
|
6825
|
+
fontEpoch: resolveOptionValue(options.fontEpoch, "font:default"),
|
|
6826
|
+
backendVersion: resolveOptionValue(options.backendVersion, delegate.fidelity),
|
|
6827
|
+
displayModeHash: resolveOptionValue(options.displayModeHash, "display:default")
|
|
6828
|
+
};
|
|
6829
|
+
}
|
|
6830
|
+
function measurementIdentityForBlock(block) {
|
|
6831
|
+
const identity = block.layoutIdentity;
|
|
6832
|
+
if (!identity) {
|
|
6833
|
+
return {
|
|
6834
|
+
blockId: block.blockId,
|
|
6835
|
+
blockPath: blockPathForBlock(block),
|
|
6836
|
+
identityHash: "identity:legacy"
|
|
6837
|
+
};
|
|
6838
|
+
}
|
|
6839
|
+
return {
|
|
6840
|
+
blockId: identity.blockId,
|
|
6841
|
+
blockPath: identity.blockPath,
|
|
6842
|
+
identityHash: hashStable({
|
|
6843
|
+
storyKey: identity.storyKey,
|
|
6844
|
+
blockId: identity.blockId,
|
|
6845
|
+
blockPath: identity.blockPath,
|
|
6846
|
+
sourceRef: identity.sourceRef,
|
|
6847
|
+
table: identity.table,
|
|
6848
|
+
list: identity.list,
|
|
6849
|
+
field: identity.field,
|
|
6850
|
+
object: identity.object
|
|
6851
|
+
})
|
|
6852
|
+
};
|
|
6853
|
+
}
|
|
6854
|
+
function blockPathForBlock(block) {
|
|
6855
|
+
return `${block.from}:${block.to}`;
|
|
6856
|
+
}
|
|
6857
|
+
function resolveOptionValue(option, fallback) {
|
|
6858
|
+
if (typeof option === "function") return option();
|
|
6859
|
+
return option ?? fallback;
|
|
6860
|
+
}
|
|
6861
|
+
function serializeCacheKey(key) {
|
|
6862
|
+
return stableStringify(key);
|
|
6863
|
+
}
|
|
6864
|
+
function estimateBytes(key, value) {
|
|
6865
|
+
return stableStringify(key).length + stableStringify(value).length;
|
|
6866
|
+
}
|
|
6867
|
+
function cloneMeasuredLineFragments(value) {
|
|
6868
|
+
return {
|
|
6869
|
+
lineCount: value.lineCount,
|
|
6870
|
+
maxLineWidth: value.maxLineWidth,
|
|
6871
|
+
lineHeights: [...value.lineHeights]
|
|
6872
|
+
};
|
|
6873
|
+
}
|
|
6874
|
+
function cloneMeasuredTableBlock(value) {
|
|
6875
|
+
return {
|
|
6876
|
+
totalHeightTwips: value.totalHeightTwips,
|
|
6877
|
+
rowHeights: [...value.rowHeights]
|
|
6878
|
+
};
|
|
6879
|
+
}
|
|
6880
|
+
function hashStable(value) {
|
|
6881
|
+
return fnv1a(stableStringify(value)).toString(36);
|
|
6882
|
+
}
|
|
6883
|
+
function stableStringify(value) {
|
|
6884
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
6885
|
+
if (Array.isArray(value)) {
|
|
6886
|
+
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
6887
|
+
}
|
|
6888
|
+
if (value instanceof Map) {
|
|
6889
|
+
return stableStringify(Array.from(value.entries()));
|
|
6890
|
+
}
|
|
6891
|
+
const object = value;
|
|
6892
|
+
const keys = Object.keys(object).filter((key) => object[key] !== void 0 && typeof object[key] !== "function").sort();
|
|
6893
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${stableStringify(object[key])}`).join(",")}}`;
|
|
6894
|
+
}
|
|
6895
|
+
function fnv1a(input) {
|
|
6896
|
+
let hash = 2166136261;
|
|
6897
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
6898
|
+
hash ^= input.charCodeAt(i);
|
|
6899
|
+
hash = Math.imul(hash, 16777619);
|
|
6900
|
+
}
|
|
6901
|
+
return hash >>> 0;
|
|
6902
|
+
}
|
|
6903
|
+
|
|
6592
6904
|
// src/runtime/layout/layout-engine-version.ts
|
|
6593
|
-
var LAYOUT_ENGINE_VERSION =
|
|
6905
|
+
var LAYOUT_ENGINE_VERSION = 93;
|
|
6594
6906
|
var LAYCACHE_SCHEMA_VERSION = 12;
|
|
6595
6907
|
|
|
6596
6908
|
// src/runtime/layout/layout-engine-instance.ts
|
|
6597
6909
|
var FULL_VIEWPORT_WINDOW_KEY = "full";
|
|
6598
6910
|
var DEFAULT_VIEWPORT_PAGE_WINDOW_BUFFER = 1;
|
|
6911
|
+
function indexLayoutIdentitiesByBlockPath(identities) {
|
|
6912
|
+
return new Map(identities.map((identity) => [identity.blockPath, identity]));
|
|
6913
|
+
}
|
|
6914
|
+
function indexEditableTargetsByBlockPath(targets) {
|
|
6915
|
+
return new Map(targets.map((target) => [target.blockPath, target]));
|
|
6916
|
+
}
|
|
6599
6917
|
function normalizeViewportPageWindow(window2) {
|
|
6600
6918
|
if (!window2) return void 0;
|
|
6601
6919
|
const buffer = Number.isFinite(window2.bufferPages) ? Math.max(0, Math.floor(window2.bufferPages ?? 0)) : DEFAULT_VIEWPORT_PAGE_WINDOW_BUFFER;
|
|
@@ -6791,8 +7109,22 @@ function recordFullRebuildReason(reasonKind) {
|
|
|
6791
7109
|
probe.invalidationCounts[totalKey] = (probe.invalidationCounts[totalKey] ?? 0) + 1;
|
|
6792
7110
|
probe.invalidationCounts[byReasonKey] = (probe.invalidationCounts[byReasonKey] ?? 0) + 1;
|
|
6793
7111
|
}
|
|
7112
|
+
function wrapMeasurementProvider(provider, measurementCache, telemetryBus) {
|
|
7113
|
+
if (!measurementCache || isCachedLayoutMeasurementProvider(provider)) {
|
|
7114
|
+
return provider;
|
|
7115
|
+
}
|
|
7116
|
+
const cacheOptions = measurementCache === true ? {} : measurementCache;
|
|
7117
|
+
return createCachedLayoutMeasurementProvider(provider, {
|
|
7118
|
+
...cacheOptions,
|
|
7119
|
+
...telemetryBus ? { telemetryBus } : {}
|
|
7120
|
+
});
|
|
7121
|
+
}
|
|
6794
7122
|
function createLayoutEngine(options = {}) {
|
|
6795
|
-
let measurementProvider =
|
|
7123
|
+
let measurementProvider = wrapMeasurementProvider(
|
|
7124
|
+
options.measurementProvider ?? createEmpiricalMeasurementProvider(),
|
|
7125
|
+
options.measurementCache,
|
|
7126
|
+
options.telemetryBus
|
|
7127
|
+
);
|
|
6796
7128
|
const autoUpgradeToCanvas = options.autoUpgradeToCanvasBackend !== false;
|
|
6797
7129
|
const telemetryBus = options.telemetryBus;
|
|
6798
7130
|
const dirtyFieldFamilies = /* @__PURE__ */ new Set();
|
|
@@ -6892,13 +7224,20 @@ function createLayoutEngine(options = {}) {
|
|
|
6892
7224
|
const pageCountBeforeRecompute = previousPageCount;
|
|
6893
7225
|
const document2 = input.document;
|
|
6894
7226
|
const viewportWindow = normalizeViewportPageWindow(input.viewportPageWindow);
|
|
7227
|
+
const layoutInputs = collectCanonicalLayoutInputs(document2);
|
|
7228
|
+
const layoutIdentitiesByBlockPath = indexLayoutIdentitiesByBlockPath(
|
|
7229
|
+
layoutInputs.layoutIdentities
|
|
7230
|
+
);
|
|
7231
|
+
const editableTargetsByBlockPath = indexEditableTargetsByBlockPath(
|
|
7232
|
+
layoutInputs.editableTargets
|
|
7233
|
+
);
|
|
6895
7234
|
const mainSurface = createEditorSurfaceSnapshot(
|
|
6896
7235
|
document2,
|
|
6897
7236
|
createSelectionSnapshot(0, 0),
|
|
6898
|
-
MAIN_STORY_TARGET
|
|
7237
|
+
MAIN_STORY_TARGET,
|
|
7238
|
+
{ editableTargetsByBlockPath, layoutIdentitiesByBlockPath }
|
|
6899
7239
|
);
|
|
6900
7240
|
const sections = buildResolvedSections(document2);
|
|
6901
|
-
const layoutInputs = collectCanonicalLayoutInputs(document2);
|
|
6902
7241
|
const fieldRegions = layoutInputs.fieldRegions;
|
|
6903
7242
|
const pageStack = buildPageStackWithSplits(
|
|
6904
7243
|
document2,
|
|
@@ -7010,10 +7349,18 @@ function createLayoutEngine(options = {}) {
|
|
|
7010
7349
|
const firstDirty = range.firstPageIndex;
|
|
7011
7350
|
if (firstDirty < 0 || firstDirty >= priorGraph.pages.length) return null;
|
|
7012
7351
|
const document2 = input.document;
|
|
7352
|
+
const layoutInputs = collectCanonicalLayoutInputs(document2);
|
|
7353
|
+
const layoutIdentitiesByBlockPath = indexLayoutIdentitiesByBlockPath(
|
|
7354
|
+
layoutInputs.layoutIdentities
|
|
7355
|
+
);
|
|
7356
|
+
const editableTargetsByBlockPath = indexEditableTargetsByBlockPath(
|
|
7357
|
+
layoutInputs.editableTargets
|
|
7358
|
+
);
|
|
7013
7359
|
const mainSurface = createEditorSurfaceSnapshot(
|
|
7014
7360
|
document2,
|
|
7015
7361
|
createSelectionSnapshot(0, 0),
|
|
7016
|
-
MAIN_STORY_TARGET
|
|
7362
|
+
MAIN_STORY_TARGET,
|
|
7363
|
+
{ editableTargetsByBlockPath, layoutIdentitiesByBlockPath }
|
|
7017
7364
|
);
|
|
7018
7365
|
const sections = buildResolvedSections(document2);
|
|
7019
7366
|
const dirtyPage = priorGraph.pages[firstDirty];
|
|
@@ -7042,7 +7389,6 @@ function createLayoutEngine(options = {}) {
|
|
|
7042
7389
|
const freshSnapshotsToRebuild = freshSnapshots.slice(0, convergenceIndex);
|
|
7043
7390
|
const convergedTailStart = convergenceIndex < freshSnapshots.length ? firstDirty + convergenceIndex : void 0;
|
|
7044
7391
|
const freshStories = resolvePageStories(freshSnapshotsToRebuild);
|
|
7045
|
-
const layoutInputs = collectCanonicalLayoutInputs(document2);
|
|
7046
7392
|
const fieldRegions = layoutInputs.fieldRegions;
|
|
7047
7393
|
const freshBodyFragmentsByPageIndex = projectSurfaceBlocksToPageFragments(
|
|
7048
7394
|
mainSurface,
|
|
@@ -7172,9 +7518,13 @@ function createLayoutEngine(options = {}) {
|
|
|
7172
7518
|
const readCachedRevision = () => cachedGraph?.revision ?? 0;
|
|
7173
7519
|
void (async () => {
|
|
7174
7520
|
try {
|
|
7175
|
-
const mod = await import("./measurement-backend-canvas-
|
|
7521
|
+
const mod = await import("./measurement-backend-canvas-F7ZYDACK.js");
|
|
7176
7522
|
const canvasProvider = mod.createCanvasBackend();
|
|
7177
|
-
measurementProvider =
|
|
7523
|
+
measurementProvider = wrapMeasurementProvider(
|
|
7524
|
+
canvasProvider,
|
|
7525
|
+
options.measurementCache,
|
|
7526
|
+
telemetryBus
|
|
7527
|
+
);
|
|
7178
7528
|
cachedKey = null;
|
|
7179
7529
|
cachedGraph = null;
|
|
7180
7530
|
cachedFormatting = null;
|
|
@@ -7259,7 +7609,11 @@ function createLayoutEngine(options = {}) {
|
|
|
7259
7609
|
},
|
|
7260
7610
|
swapMeasurementProvider(provider) {
|
|
7261
7611
|
const previousFidelity = measurementProvider.fidelity;
|
|
7262
|
-
measurementProvider =
|
|
7612
|
+
measurementProvider = wrapMeasurementProvider(
|
|
7613
|
+
provider,
|
|
7614
|
+
options.measurementCache,
|
|
7615
|
+
telemetryBus
|
|
7616
|
+
);
|
|
7263
7617
|
if (previousFidelity !== provider.fidelity) {
|
|
7264
7618
|
cachedKey = null;
|
|
7265
7619
|
cachedGraph = null;
|
|
@@ -7288,6 +7642,10 @@ function createLayoutEngine(options = {}) {
|
|
|
7288
7642
|
cachedFormatting = null;
|
|
7289
7643
|
cachedMapper = null;
|
|
7290
7644
|
},
|
|
7645
|
+
getMeasurementCacheStats() {
|
|
7646
|
+
if (!isCachedLayoutMeasurementProvider(measurementProvider)) return null;
|
|
7647
|
+
return measurementProvider.measurementCacheStats();
|
|
7648
|
+
},
|
|
7291
7649
|
/**
|
|
7292
7650
|
* L7 Phase 2.5 — seed the cached graph from a prerender envelope.
|
|
7293
7651
|
* Populates both `cachedGraph` and `cachedKey` (keyed on the provided
|