@beyondwork/docx-react-component 1.0.50 → 1.0.52
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/README.md +8 -5
- package/package.json +40 -29
- package/src/api/public-types.ts +9 -0
- package/src/runtime/layout/layout-engine-version.ts +42 -1
- package/src/runtime/layout/layout-invalidation.ts +62 -5
- package/src/runtime/layout/page-graph.ts +94 -1
- package/src/runtime/render/index.ts +7 -0
- package/src/runtime/render/render-frame-diff.ts +298 -0
- package/src/runtime/render/render-frame-types.ts +8 -1
- package/src/runtime/render/render-kernel.ts +40 -10
- package/src/runtime/selection/cursor-ops.ts +202 -0
- package/src/runtime/selection/index.ts +91 -0
- package/src/runtime/surface-projection.ts +10 -1
- package/src/runtime/theme-color-resolver.ts +46 -0
- package/src/ui/WordReviewEditor.tsx +3 -0
- package/src/ui-tailwind/chart/layout/axis-layout.ts +344 -0
- package/src/ui-tailwind/chart/layout/plot-area.ts +344 -0
- package/src/ui-tailwind/chart/render/number-format.ts +287 -0
package/README.md
CHANGED
|
@@ -234,11 +234,14 @@ Engineering work is organized into 9 lanes (5 active now + 2 later polish + 2 fi
|
|
|
234
234
|
| 3b | [**OOXML Fidelity & Round-Trip**](docs/plans/lane-3b-ooxml-fidelity.md) | **55%** | V1 + O3 + O4 + O2 (all 4 slices) + V7 closed; 🚨 O8 + L2.c + V6 + V2a/b/c + R3–R5 backlog |
|
|
235
235
|
| 4 | [**Collab + CLM/Vallor**](docs/plans/lane-4-collab-clm-vallor.md) | **80%** | P1–P14 + all P11 sub-bullets + P12 + perf-parity + P13 A/B/C shipped; P15 / P16 / P17 left |
|
|
236
236
|
| 5 | [**Charts (independent)**](docs/plans/lane-5-charts.md) | **30%** | Stages 0–2 shipped (parsers + theme); Stages 3–7 (SVG renderers + pixel-diff) left |
|
|
237
|
-
|
|
|
238
|
-
|
|
|
239
|
-
|
|
|
240
|
-
|
|
|
241
|
-
|
|
|
237
|
+
| 6a | [**Tokens & Theme Foundation**](docs/plans/lane-6a-tokens-theme-foundation.md) | **~25%** | Active (no gate) — canonical token substrate: brand-accent flip, semantic families, scope-tint tokens, chart palette, hex eviction, density + reduced-motion plumbing |
|
|
238
|
+
| 6b | [**Shell & Workspace Chrome**](docs/plans/lane-6b-shell-workspace-chrome.md) | **~15%** | Gated on 6a.S1+S2 — shell header + toolbar + status + alert banner + unsaved modal + collab chrome restyle; mode-dock decommission; TwCommandPalette |
|
|
239
|
+
| 6c | [**Context & Review Surfaces**](docs/plans/lane-6c-context-review-surfaces.md) | **~15%** | Gated on 6a.S1+S2 — selection toolbar + suggestion card + rail + scope + context toolbars + health panel restyle; TwCommentPreview / TwEmptyState / TwShortcutHint |
|
|
240
|
+
| 6d | [**Visual Fidelity**](docs/plans/lane-6d-visual-fidelity.md) | **~20%** | Gated on 6a.S1+S2 + external-lane deps — L8 A/B/C shipped; L8 Phase D + P11 overlays + P7 + P12 + P14 next |
|
|
241
|
+
| 7a | [**Visual Fidelity Register**](docs/plans/lane-7a-visual-fidelity-register.md) | **0%** | LATER (gated on 6a–6d) — V5 covers, V6 REF/PAGEREF, V7 cascade audit |
|
|
242
|
+
| 7b | [**Revision & Redline Completion**](docs/plans/lane-7b-revision-redline-completion.md) | **0%** | LATER (gated on 6a–6d) — X4.a/b structural table revisions, X5 ffData, move-pairing |
|
|
243
|
+
| 7c | [**Preservation & Format Coverage**](docs/plans/lane-7c-preservation-format-coverage.md) | **0%** | LATER (gated on 6a–6d) — O6 Strict, OLE preserve-only, picture-SDT, w14/kern/VML defer |
|
|
244
|
+
| 7d | [**Platform Hardening & Hygiene**](docs/plans/lane-7d-platform-hardening-hygiene.md) | **0%** | LATER (gated on 6a–6d) — harness-crash-hardening, fastload activation, worktree consolidation |
|
|
242
245
|
| 8 | [**API Ergonomics / Errors / BC**](docs/plans/lane-8-api-ergonomics.md) | **40%** | LATER — Tracks A+C shipped (error catalog + ergonomics fixes); Tracks B+D+E + public-api.md end-to-end refactor remain |
|
|
243
246
|
| 9 | [**Shipping (v2.0.0)**](docs/plans/lane-9-shipping.md) | **0%** | FINAL — API freeze, semver discipline, changelog, telemetry, customer migration guides, doc completeness audit |
|
|
244
247
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beyondwork/docx-react-component",
|
|
3
3
|
"publisher": "beyondwork",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.52",
|
|
5
5
|
"description": "Embeddable React Word (docx) editor with review, comments, tracked changes, and round-trip OOXML fidelity.",
|
|
6
|
+
"packageManager": "pnpm@10.30.3",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"sideEffects": [
|
|
8
9
|
"**/*.css"
|
|
@@ -92,6 +93,35 @@
|
|
|
92
93
|
"./ui-tailwind/theme/editor-theme.css": "./src/ui-tailwind/theme/editor-theme.css"
|
|
93
94
|
},
|
|
94
95
|
"types": "./src/index.ts",
|
|
96
|
+
"scripts": {
|
|
97
|
+
"build": "tsup",
|
|
98
|
+
"test": "bash scripts/run-workspace-tests.sh",
|
|
99
|
+
"test:repo": "node scripts/ci-check-layout-engine-version.mjs && node scripts/run-repo-tests.mjs core",
|
|
100
|
+
"test:repo:all": "node scripts/run-repo-tests.mjs all",
|
|
101
|
+
"test:repo:optional": "node scripts/run-repo-tests.mjs optional",
|
|
102
|
+
"test:repo:browser-ui": "node scripts/run-repo-tests.mjs browser-ui",
|
|
103
|
+
"test:wcag-audit": "node scripts/run-repo-tests.mjs wcag-audit",
|
|
104
|
+
"test:harness": "pnpm --filter @docx-react-component/react-word-editor-harness test",
|
|
105
|
+
"test:visual": "VISUAL_SMOKE_PROFILE=bare pnpm exec playwright test --project=chromium",
|
|
106
|
+
"test:visual:chrome": "VISUAL_SMOKE_PROFILE=chrome-cycle pnpm exec playwright test --project=chromium",
|
|
107
|
+
"visual:list-runs": "node scripts/visual-smoke-list-runs.mjs",
|
|
108
|
+
"mcp:visual-smoke": "node scripts/visual-smoke-mcp.mjs",
|
|
109
|
+
"lint": "pnpm run lint:no-authored-js && pnpm run lint:docs-contracts && pnpm run lint:tsgo && pnpm run lint:tsgo:harness",
|
|
110
|
+
"lint:docs-contracts": "bash scripts/check-reference-load-contract.sh",
|
|
111
|
+
"lint:no-authored-js": "bash scripts/check-no-authored-js.sh",
|
|
112
|
+
"lint:tsgo": "tsgo --noEmit -p tsconfig.build.json",
|
|
113
|
+
"lint:tsgo:harness": "pnpm --filter @docx-react-component/react-word-editor-harness lint:tsgo",
|
|
114
|
+
"context7:api-check": "bash scripts/context7-export-env.sh run bash scripts/context7-api-check.sh",
|
|
115
|
+
"wave:doctor": "bash scripts/context7-export-env.sh run pnpm exec wave doctor --json",
|
|
116
|
+
"wave:dry-run": "bash scripts/context7-export-env.sh run pnpm exec wave launch --lane main --dry-run --no-dashboard",
|
|
117
|
+
"wave:launch": "bash scripts/context7-export-env.sh run pnpm exec wave launch --lane main",
|
|
118
|
+
"wave:launch:managed": "bash scripts/wave-launch.sh",
|
|
119
|
+
"wave:status": "bash scripts/wave-status.sh",
|
|
120
|
+
"wave:watch": "bash scripts/wave-watch.sh --follow",
|
|
121
|
+
"wave:dashboard:current": "bash scripts/wave-dashboard-attach.sh current",
|
|
122
|
+
"wave:dashboard:global": "bash scripts/wave-dashboard-attach.sh global",
|
|
123
|
+
"harness:dev": "pnpm --filter @docx-react-component/react-word-editor-harness dev"
|
|
124
|
+
},
|
|
95
125
|
"keywords": [
|
|
96
126
|
"docx",
|
|
97
127
|
"word",
|
|
@@ -175,33 +205,14 @@
|
|
|
175
205
|
"y-protocols": "^1.0.7",
|
|
176
206
|
"yjs": "^13.6.30"
|
|
177
207
|
},
|
|
178
|
-
"
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
"
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
"test:visual": "VISUAL_SMOKE_PROFILE=bare pnpm exec playwright test --project=chromium",
|
|
188
|
-
"test:visual:chrome": "VISUAL_SMOKE_PROFILE=chrome-cycle pnpm exec playwright test --project=chromium",
|
|
189
|
-
"visual:list-runs": "node scripts/visual-smoke-list-runs.mjs",
|
|
190
|
-
"mcp:visual-smoke": "node scripts/visual-smoke-mcp.mjs",
|
|
191
|
-
"lint": "pnpm run lint:no-authored-js && pnpm run lint:docs-contracts && pnpm run lint:tsgo && pnpm run lint:tsgo:harness",
|
|
192
|
-
"lint:docs-contracts": "bash scripts/check-reference-load-contract.sh",
|
|
193
|
-
"lint:no-authored-js": "bash scripts/check-no-authored-js.sh",
|
|
194
|
-
"lint:tsgo": "tsgo --noEmit -p tsconfig.build.json",
|
|
195
|
-
"lint:tsgo:harness": "pnpm --filter @docx-react-component/react-word-editor-harness lint:tsgo",
|
|
196
|
-
"context7:api-check": "bash scripts/context7-export-env.sh run bash scripts/context7-api-check.sh",
|
|
197
|
-
"wave:doctor": "bash scripts/context7-export-env.sh run pnpm exec wave doctor --json",
|
|
198
|
-
"wave:dry-run": "bash scripts/context7-export-env.sh run pnpm exec wave launch --lane main --dry-run --no-dashboard",
|
|
199
|
-
"wave:launch": "bash scripts/context7-export-env.sh run pnpm exec wave launch --lane main",
|
|
200
|
-
"wave:launch:managed": "bash scripts/wave-launch.sh",
|
|
201
|
-
"wave:status": "bash scripts/wave-status.sh",
|
|
202
|
-
"wave:watch": "bash scripts/wave-watch.sh --follow",
|
|
203
|
-
"wave:dashboard:current": "bash scripts/wave-dashboard-attach.sh current",
|
|
204
|
-
"wave:dashboard:global": "bash scripts/wave-dashboard-attach.sh global",
|
|
205
|
-
"harness:dev": "pnpm --filter @docx-react-component/react-word-editor-harness dev"
|
|
208
|
+
"pnpm": {
|
|
209
|
+
"onlyBuiltDependencies": [
|
|
210
|
+
"esbuild",
|
|
211
|
+
"sharp"
|
|
212
|
+
],
|
|
213
|
+
"overrides": {
|
|
214
|
+
"react": "19.2.4",
|
|
215
|
+
"react-dom": "19.2.4"
|
|
216
|
+
}
|
|
206
217
|
}
|
|
207
218
|
}
|
package/src/api/public-types.ts
CHANGED
|
@@ -3025,6 +3025,15 @@ export interface WordReviewEditorRef {
|
|
|
3025
3025
|
setImageFrame(mediaId: string, offsets: { horizontalOffsetEmu?: number; verticalOffsetEmu?: number }): void;
|
|
3026
3026
|
setWorkflowOverlay(overlay: WorkflowOverlay): void;
|
|
3027
3027
|
clearWorkflowOverlay(): void;
|
|
3028
|
+
/**
|
|
3029
|
+
* Read the current runtime-backed `WorkflowOverlay`, or `null` when no
|
|
3030
|
+
* overlay is active. Hosts use this for read-modify-write flows against
|
|
3031
|
+
* `setWorkflowOverlay(...)` — notably to preserve engine-authored scopes
|
|
3032
|
+
* minted via `addScope(...)` when updating candidates / work items.
|
|
3033
|
+
* Returns a defensive clone; mutating the returned object does not affect
|
|
3034
|
+
* runtime state.
|
|
3035
|
+
*/
|
|
3036
|
+
getWorkflowOverlay(): WorkflowOverlay | null;
|
|
3028
3037
|
setSharedWorkflowState(state: SharedWorkflowState | null): void;
|
|
3029
3038
|
getWorkflowScopeSnapshot(): WorkflowScopeSnapshot | null;
|
|
3030
3039
|
getInteractionGuardSnapshot(): InteractionGuardSnapshot;
|
|
@@ -52,8 +52,49 @@
|
|
|
52
52
|
* `frame.decorationIndex`. Cache envelopes from version 5 are
|
|
53
53
|
* invalidated on load because the anchor-index public shape
|
|
54
54
|
* changed even though pixel geometry did not.
|
|
55
|
+
* 7 — Lane 3a P9 Phase A2. Predicted-delta-aware anchor shifts.
|
|
56
|
+
* `byRuntimeOffset` and `bySelection` now compensate incoming
|
|
57
|
+
* offsets by `sumDeltasBefore(pendingDeltas, offset)` before the
|
|
58
|
+
* map lookup so chrome rects stay aligned with the caret during
|
|
59
|
+
* the predicted-dispatch window. No cached-geometry change; pure
|
|
60
|
+
* resolver behavior change. Cache envelopes from v6 auto-
|
|
61
|
+
* invalidate because the anchor-index now honors the previously-
|
|
62
|
+
* stubbed `pendingDeltas` input.
|
|
63
|
+
* 8 — Lane 3a P10 Phase B. `frame_diff` kernel event now carries a
|
|
64
|
+
* full `RenderFrameDiff` (addedPages / removedPages /
|
|
65
|
+
* unchangedPages / changedPages) instead of the prior
|
|
66
|
+
* `pageRange` payload. New module `src/runtime/render/render-frame-
|
|
67
|
+
* diff.ts` exports `diffRenderFrames(prev, next)` which computes
|
|
68
|
+
* the structural diff (blockId + rounded bbox + decoration-ref
|
|
69
|
+
* intersection — NOT reference equality, because the layout
|
|
70
|
+
* engine rebuilds fragment objects on every pass). Page-stack
|
|
71
|
+
* consumers subscribe to `frame_diff` and memoize unchanged pages
|
|
72
|
+
* to skip React reconciliation. No cached-geometry change; cache
|
|
73
|
+
* envelopes from v7 invalidate because the event shape changed.
|
|
74
|
+
* 9 — Lane 3a P10 Phase C. `analyzeInvalidation` for
|
|
75
|
+
* `section-change` now returns `scope: "bounded"` with
|
|
76
|
+
* `dirtyPageRange.firstPageIndex` set to the affected section's
|
|
77
|
+
* first rendered page (was `scope: "full"`). Pages in earlier
|
|
78
|
+
* sections retain pagination; pages in and after the affected
|
|
79
|
+
* section rebuild. Fallback to full rebuild when the target
|
|
80
|
+
* section has no materialized pages. No cached-geometry change;
|
|
81
|
+
* cache envelopes from v8 invalidate because the invalidation
|
|
82
|
+
* classifier changed the scope contract.
|
|
83
|
+
* 10 — Lane 3a P10 Phase D1. `spliceGraph` detects structural
|
|
84
|
+
* convergence between the fresh tail and the prior tail and
|
|
85
|
+
* reuses the prior `RuntimePageNode` reference for every page
|
|
86
|
+
* that matches on (sectionIndex, pageInSection, startOffset,
|
|
87
|
+
* endOffset, isBlankFiller, body / header / footer / footnote
|
|
88
|
+
* fragmentId lists). Downstream caches — render-frame-diff
|
|
89
|
+
* (`unchangedPages`), prerender cache (stable pageId), React
|
|
90
|
+
* page keys — observe stable references for the common case
|
|
91
|
+
* where a localized edit doesn't shift content forward. Fresh
|
|
92
|
+
* nodes are substituted from the first mismatch onward. No
|
|
93
|
+
* pixel-geometry change; cache envelopes from v9 invalidate
|
|
94
|
+
* because page-node identity semantics on bounded splices
|
|
95
|
+
* changed.
|
|
55
96
|
*/
|
|
56
|
-
export const LAYOUT_ENGINE_VERSION =
|
|
97
|
+
export const LAYOUT_ENGINE_VERSION = 10 as const;
|
|
57
98
|
|
|
58
99
|
/**
|
|
59
100
|
* Serialization schema version for the LayCache payload (the cache envelope
|
|
@@ -7,6 +7,21 @@
|
|
|
7
7
|
* boundary inside the dirty range, style change, numbering change, etc.) we
|
|
8
8
|
* fall back to a full rebuild. The `scope` field declares which path the
|
|
9
9
|
* engine should follow.
|
|
10
|
+
*
|
|
11
|
+
* Bounded scopes today:
|
|
12
|
+
* - `content-edit`: bounded to the first page whose range overlaps the
|
|
13
|
+
* edit offsets (§analyzeContentEdit).
|
|
14
|
+
* - `section-change`: bounded to the first page of the affected section
|
|
15
|
+
* onward — P10 Phase C (§analyzeSectionChange).
|
|
16
|
+
* - `numbering-change`: bounded to the whole document (dirtyPageRange
|
|
17
|
+
* spans pages [0..end]); tightening to the earliest page referencing
|
|
18
|
+
* the numbering instance requires per-fragment numbering metadata
|
|
19
|
+
* on `RuntimeBlockFragment` which is not available today.
|
|
20
|
+
*
|
|
21
|
+
* Remaining full-rebuild triggers:
|
|
22
|
+
* - `styles-change` / `theme-change`: without per-fragment style-chain
|
|
23
|
+
* metadata on the graph, we cannot safely tighten these. Flagged as
|
|
24
|
+
* follow-up for when `RuntimeBlockFragment.resolvedStyleChain` lands.
|
|
10
25
|
*/
|
|
11
26
|
|
|
12
27
|
import type { LayoutInvalidationReason } from "./paginated-layout-engine.ts";
|
|
@@ -252,15 +267,57 @@ function analyzeSectionChange(
|
|
|
252
267
|
reason: Extract<LayoutInvalidationReason, { kind: "section-change" }>,
|
|
253
268
|
graph: RuntimePageGraph,
|
|
254
269
|
): InvalidationResult {
|
|
255
|
-
//
|
|
256
|
-
//
|
|
270
|
+
// P10 Phase C — section property changes affect pages from the first
|
|
271
|
+
// page of the affected section onward. Earlier pages in earlier
|
|
272
|
+
// sections retain their pagination. When the target section has no
|
|
273
|
+
// materialized pages (e.g. section-change for a section that hasn't
|
|
274
|
+
// rendered yet), fall back to a full recompute.
|
|
275
|
+
const firstPageOfSection = findFirstPageIndexForSection(
|
|
276
|
+
graph,
|
|
277
|
+
reason.sectionIndex,
|
|
278
|
+
);
|
|
279
|
+
if (firstPageOfSection < 0) {
|
|
280
|
+
return {
|
|
281
|
+
scope: "full",
|
|
282
|
+
requiresFullRecompute: true,
|
|
283
|
+
dirtySectionRange: {
|
|
284
|
+
from: reason.sectionIndex,
|
|
285
|
+
to: Math.max(0, graph.sections.length - 1),
|
|
286
|
+
},
|
|
287
|
+
dirtyFieldFamilies: ["PAGE", "NUMPAGES", "SECTIONPAGES"],
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Bounded: rebuild from the affected section's first page to the end
|
|
292
|
+
// of the document. Rebuilding to the end (not just the section's last
|
|
293
|
+
// page) is required because a section property change — page size,
|
|
294
|
+
// margins, column count — can propagate to downstream sections if a
|
|
295
|
+
// `nextPage` / `evenPage` / `oddPage` break shifts.
|
|
257
296
|
return {
|
|
258
|
-
scope: "
|
|
259
|
-
requiresFullRecompute:
|
|
297
|
+
scope: "bounded",
|
|
298
|
+
requiresFullRecompute: false,
|
|
299
|
+
dirtyPageRange: {
|
|
300
|
+
firstPageIndex: firstPageOfSection,
|
|
301
|
+
lastPageIndex: Math.max(0, graph.pages.length - 1),
|
|
302
|
+
},
|
|
260
303
|
dirtySectionRange: {
|
|
261
304
|
from: reason.sectionIndex,
|
|
262
|
-
to: graph.sections.length - 1,
|
|
305
|
+
to: Math.max(0, graph.sections.length - 1),
|
|
263
306
|
},
|
|
264
307
|
dirtyFieldFamilies: ["PAGE", "NUMPAGES", "SECTIONPAGES"],
|
|
265
308
|
};
|
|
266
309
|
}
|
|
310
|
+
|
|
311
|
+
function findFirstPageIndexForSection(
|
|
312
|
+
graph: RuntimePageGraph,
|
|
313
|
+
sectionIndex: number,
|
|
314
|
+
): number {
|
|
315
|
+
for (let i = 0; i < graph.pages.length; i += 1) {
|
|
316
|
+
const page = graph.pages[i]!;
|
|
317
|
+
if (page.isBlankFiller) continue;
|
|
318
|
+
if (page.sectionIndex === sectionIndex) return i;
|
|
319
|
+
}
|
|
320
|
+
// No page found for this section — section may be empty or past the
|
|
321
|
+
// rendered tail. Caller treats this as a full-rebuild trigger.
|
|
322
|
+
return -1;
|
|
323
|
+
}
|
|
@@ -522,7 +522,34 @@ export function spliceGraph(
|
|
|
522
522
|
graphRevision += 1;
|
|
523
523
|
const clampedFirst = Math.max(0, Math.min(firstDirtyIndex, prior.pages.length));
|
|
524
524
|
const preserved = prior.pages.slice(0, clampedFirst);
|
|
525
|
-
|
|
525
|
+
|
|
526
|
+
// P10 Phase D1 — convergence-point tail reuse. When a fresh page at
|
|
527
|
+
// index `clampedFirst + i` structurally matches the prior graph's
|
|
528
|
+
// page at the same index (same startOffset, endOffset, sectionIndex,
|
|
529
|
+
// fragment count), substitute the prior `RuntimePageNode` so
|
|
530
|
+
// downstream caches (render-frame-diff, prerender cache, React page
|
|
531
|
+
// keys) observe a stable reference. Stops at the first mismatch —
|
|
532
|
+
// everything after that re-pagination produced fresh has to flow
|
|
533
|
+
// through the fresh nodes because pagination may have shifted it.
|
|
534
|
+
// When prior has fewer pages past clampedFirst than fresh (e.g., an
|
|
535
|
+
// edit added pages), `reusedCount` caps at the prior length so we
|
|
536
|
+
// don't index past the prior tail.
|
|
537
|
+
const priorTail = prior.pages.slice(clampedFirst);
|
|
538
|
+
const reuseLimit = Math.min(priorTail.length, freshPages.length);
|
|
539
|
+
let reusedCount = 0;
|
|
540
|
+
while (
|
|
541
|
+
reusedCount < reuseLimit &&
|
|
542
|
+
pageNodesStructurallyEqual(priorTail[reusedCount]!, freshPages[reusedCount]!)
|
|
543
|
+
) {
|
|
544
|
+
reusedCount += 1;
|
|
545
|
+
}
|
|
546
|
+
const stableTailPrefix = priorTail.slice(0, reusedCount);
|
|
547
|
+
const divergentTail = freshPages.slice(reusedCount);
|
|
548
|
+
const nextPages: RuntimePageNode[] = [
|
|
549
|
+
...preserved,
|
|
550
|
+
...stableTailPrefix,
|
|
551
|
+
...divergentTail,
|
|
552
|
+
];
|
|
526
553
|
|
|
527
554
|
const survivingPageIds = new Set(nextPages.map((page) => page.pageId));
|
|
528
555
|
const mergedFragments: RuntimeBlockFragment[] = [];
|
|
@@ -558,3 +585,69 @@ export function spliceGraph(
|
|
|
558
585
|
contentPageCount,
|
|
559
586
|
};
|
|
560
587
|
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Compare two `RuntimePageNode`s by the fields that matter for
|
|
591
|
+
* pagination identity — if these all match, the fresh node represents
|
|
592
|
+
* the same content the prior graph already paginated. Used by
|
|
593
|
+
* `spliceGraph` to detect convergence between the fresh tail and the
|
|
594
|
+
* prior tail (P10 Phase D1) so downstream caches see stable references.
|
|
595
|
+
*
|
|
596
|
+
* We deliberately compare fragmentIds rather than full fragment objects
|
|
597
|
+
* because fragments are re-minted on each build even when they project
|
|
598
|
+
* identical canonical content; their id is derived from a stable
|
|
599
|
+
* structural hash.
|
|
600
|
+
*/
|
|
601
|
+
function pageNodesStructurallyEqual(
|
|
602
|
+
a: RuntimePageNode,
|
|
603
|
+
b: RuntimePageNode,
|
|
604
|
+
): boolean {
|
|
605
|
+
if (a.sectionIndex !== b.sectionIndex) return false;
|
|
606
|
+
if (a.pageInSection !== b.pageInSection) return false;
|
|
607
|
+
if (a.startOffset !== b.startOffset) return false;
|
|
608
|
+
if (a.endOffset !== b.endOffset) return false;
|
|
609
|
+
if (a.isBlankFiller !== b.isBlankFiller) return false;
|
|
610
|
+
if (a.regions.body.fragmentIds.length !== b.regions.body.fragmentIds.length) {
|
|
611
|
+
return false;
|
|
612
|
+
}
|
|
613
|
+
for (let i = 0; i < a.regions.body.fragmentIds.length; i += 1) {
|
|
614
|
+
if (a.regions.body.fragmentIds[i] !== b.regions.body.fragmentIds[i]) {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
// Header / footer fragment lists: compare if present on either side.
|
|
619
|
+
if (!optionalRegionFragmentsEqual(a.regions.header, b.regions.header)) {
|
|
620
|
+
return false;
|
|
621
|
+
}
|
|
622
|
+
if (!optionalRegionFragmentsEqual(a.regions.footer, b.regions.footer)) {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
// Footnote-area regions: compare count + per-region fragment lists.
|
|
626
|
+
const aFoot = a.regions.footnotes ?? [];
|
|
627
|
+
const bFoot = b.regions.footnotes ?? [];
|
|
628
|
+
if (aFoot.length !== bFoot.length) return false;
|
|
629
|
+
for (let i = 0; i < aFoot.length; i += 1) {
|
|
630
|
+
if (!regionFragmentsEqual(aFoot[i]!, bFoot[i]!)) return false;
|
|
631
|
+
}
|
|
632
|
+
return true;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function optionalRegionFragmentsEqual(
|
|
636
|
+
a: RuntimePageRegion | undefined,
|
|
637
|
+
b: RuntimePageRegion | undefined,
|
|
638
|
+
): boolean {
|
|
639
|
+
if (!a && !b) return true;
|
|
640
|
+
if (!a || !b) return false;
|
|
641
|
+
return regionFragmentsEqual(a, b);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function regionFragmentsEqual(
|
|
645
|
+
a: RuntimePageRegion,
|
|
646
|
+
b: RuntimePageRegion,
|
|
647
|
+
): boolean {
|
|
648
|
+
if (a.fragmentIds.length !== b.fragmentIds.length) return false;
|
|
649
|
+
for (let i = 0; i < a.fragmentIds.length; i += 1) {
|
|
650
|
+
if (a.fragmentIds[i] !== b.fragmentIds[i]) return false;
|
|
651
|
+
}
|
|
652
|
+
return true;
|
|
653
|
+
}
|
|
@@ -30,6 +30,13 @@ export {
|
|
|
30
30
|
type LockedRangeInput,
|
|
31
31
|
} from "./decoration-resolver.ts";
|
|
32
32
|
|
|
33
|
+
export {
|
|
34
|
+
diffRenderFrames,
|
|
35
|
+
isEmptyDiff,
|
|
36
|
+
type ChangedPageEntry,
|
|
37
|
+
type RenderFrameDiff,
|
|
38
|
+
} from "./render-frame-diff.ts";
|
|
39
|
+
|
|
33
40
|
export {
|
|
34
41
|
DEFAULT_PX_PER_TWIP,
|
|
35
42
|
EMPTY_DECORATION_INDEX,
|