@beyondwork/docx-react-component 1.0.106 → 1.0.109
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/package.json +19 -5
- package/src/api/geometry-overlay-rects.ts +5 -0
- package/src/api/package-version.ts +1 -1
- package/src/api/page-anchor-id.ts +5 -0
- package/src/api/public-types.ts +16 -9
- package/src/api/table-node-specs.ts +6 -0
- package/src/api/v3/_create.ts +2 -1
- package/src/api/v3/_page-anchor-id.ts +52 -0
- package/src/api/v3/_runtime-handle.ts +92 -1
- package/src/api/v3/ai/_audit-time.ts +5 -0
- package/src/api/v3/ai/_pe2-evidence.ts +38 -0
- package/src/api/v3/ai/attach.ts +7 -2
- package/src/api/v3/ai/replacement.ts +101 -18
- package/src/api/v3/ai/resolve.ts +2 -2
- package/src/api/v3/ai/review.ts +177 -3
- package/src/api/v3/index.ts +1 -0
- package/src/api/v3/runtime/collab.ts +462 -0
- package/src/api/v3/runtime/document.ts +503 -20
- package/src/api/v3/runtime/geometry.ts +97 -0
- package/src/api/v3/runtime/layout.ts +744 -0
- package/src/api/v3/runtime/perf-probe.ts +14 -0
- package/src/api/v3/runtime/viewport.ts +9 -8
- package/src/api/v3/ui/_types.ts +149 -55
- package/src/api/v3/ui/chrome-preset-model.ts +5 -5
- package/src/api/v3/ui/debug.ts +115 -2
- package/src/api/v3/ui/index.ts +13 -0
- package/src/api/v3/ui/overlays.ts +0 -8
- package/src/api/v3/ui/surface.ts +56 -0
- package/src/api/v3/ui/viewport.ts +22 -9
- package/src/core/commands/image-commands.ts +1 -0
- package/src/core/commands/index.ts +6 -0
- package/src/core/schema/text-schema.ts +43 -5
- package/src/core/selection/mapping.ts +8 -1
- package/src/core/selection/review-anchors.ts +5 -1
- package/src/core/state/text-transaction.ts +8 -2
- package/src/io/export/serialize-revisions.ts +149 -1
- package/src/io/normalize/normalize-text.ts +6 -0
- package/src/io/ooxml/parse-bookmark-references.ts +55 -0
- package/src/io/ooxml/parse-fields.ts +24 -2
- package/src/io/ooxml/parse-headers-footers.ts +38 -5
- package/src/io/ooxml/parse-main-document.ts +153 -9
- package/src/io/ooxml/parse-numbering.ts +20 -0
- package/src/io/ooxml/parse-revisions.ts +19 -8
- package/src/io/opc/package-reader.ts +98 -8
- package/src/model/anchor.ts +4 -3
- package/src/model/canonical-document.ts +220 -2
- package/src/model/canonical-hash.ts +221 -0
- package/src/model/canonical-layout-inputs.ts +245 -6
- package/src/model/layout/index.ts +1 -0
- package/src/model/layout/page-graph-types.ts +118 -1
- package/src/model/review/revision-types.ts +14 -3
- package/src/preservation/store.ts +20 -4
- package/src/review/README.md +1 -1
- package/src/review/store/revision-actions.ts +14 -2
- package/src/runtime/collab/event-types.ts +67 -1
- package/src/runtime/collab/runtime-collab-sync.ts +177 -5
- package/src/runtime/diagnostics/layout-guard-warning.ts +18 -0
- package/src/runtime/document-heading-outline.ts +147 -0
- package/src/runtime/document-navigation.ts +8 -243
- package/src/runtime/document-runtime.ts +240 -97
- package/src/runtime/edit-dispatch/dispatch-text-command.ts +11 -0
- package/src/runtime/formatting/layout-inputs.ts +38 -5
- package/src/runtime/formatting/numbering/geometry.ts +28 -2
- package/src/runtime/geometry/adjacent-geometry-intake.ts +835 -0
- package/src/runtime/geometry/caret-geometry.ts +5 -6
- package/src/runtime/geometry/geometry-facet.ts +60 -10
- package/src/runtime/geometry/geometry-index.ts +591 -20
- package/src/runtime/geometry/geometry-types.ts +59 -0
- package/src/runtime/geometry/hit-test.ts +11 -1
- package/src/runtime/geometry/overlay-rects.ts +5 -3
- package/src/runtime/geometry/project-anchors.ts +1 -1
- package/src/runtime/geometry/word-layout-v2-line-intake.ts +323 -0
- package/src/runtime/layout/index.ts +6 -0
- package/src/runtime/layout/layout-engine-instance.ts +6 -1
- package/src/runtime/layout/layout-engine-version.ts +181 -16
- package/src/runtime/layout/layout-facet-types.ts +6 -0
- package/src/runtime/layout/page-graph.ts +21 -4
- package/src/runtime/layout/paginated-layout-engine.ts +139 -15
- package/src/runtime/layout/project-block-fragments.ts +265 -7
- package/src/runtime/layout/public-facet.ts +78 -24
- package/src/runtime/layout/table-row-continuation-contract.ts +107 -0
- package/src/runtime/layout/table-row-split.ts +92 -35
- package/src/runtime/prerender/cache-envelope.ts +2 -2
- package/src/runtime/prerender/cache-key.ts +5 -4
- package/src/runtime/prerender/customxml-cache.ts +0 -1
- package/src/runtime/render/render-kernel.ts +1 -1
- package/src/runtime/revision-runtime.ts +112 -10
- package/src/runtime/scopes/_scope-dependencies.ts +1 -0
- package/src/runtime/scopes/action-validation.ts +22 -2
- package/src/runtime/scopes/capabilities.ts +316 -0
- package/src/runtime/scopes/compile-scope-bundle.ts +14 -0
- package/src/runtime/scopes/compiler-service.ts +108 -4
- package/src/runtime/scopes/content-control-evidence.ts +79 -0
- package/src/runtime/scopes/create-issue.ts +5 -5
- package/src/runtime/scopes/evidence.ts +91 -0
- package/src/runtime/scopes/formatting/apply.ts +2 -0
- package/src/runtime/scopes/geometry-evidence.ts +130 -0
- package/src/runtime/scopes/index.ts +54 -0
- package/src/runtime/scopes/issue-lifecycle.ts +224 -0
- package/src/runtime/scopes/layout-evidence.ts +374 -0
- package/src/runtime/scopes/multi-paragraph-refusal.ts +37 -0
- package/src/runtime/scopes/preservation-boundary.ts +7 -1
- package/src/runtime/scopes/replacement/apply.ts +97 -34
- package/src/runtime/scopes/scope-kinds/paragraph.ts +108 -12
- package/src/runtime/scopes/semantic-scope-types.ts +242 -3
- package/src/runtime/scopes/visualization.ts +28 -0
- package/src/runtime/surface-projection.ts +44 -5
- package/src/runtime/telemetry/perf-probe.ts +216 -0
- package/src/runtime/virtualized-rendering.ts +36 -1
- package/src/runtime/workflow/ai-issue-lifecycle.ts +253 -0
- package/src/runtime/workflow/coordinator.ts +39 -11
- package/src/runtime/workflow/derived-scope-resolver.ts +63 -9
- package/src/runtime/workflow/index.ts +3 -0
- package/src/runtime/workflow/overlay-lane-types.ts +58 -0
- package/src/runtime/workflow/overlay-lanes.ts +168 -10
- package/src/runtime/workflow/overlay-store.ts +2 -2
- package/src/runtime/workflow/redline-posture-calibration.ts +257 -0
- package/src/runtime/workflow/word-field-matrix-calibration.ts +231 -0
- package/src/session/_sync-legacy.ts +17 -27
- package/src/session/import/loader.ts +6 -4
- package/src/session/import/source-package-evidence.ts +186 -2
- package/src/session/index.ts +5 -6
- package/src/session/session.ts +30 -56
- package/src/session/types.ts +8 -13
- package/src/shell/session-bootstrap.ts +155 -81
- package/src/ui/WordReviewEditor.tsx +520 -12
- package/src/ui/editor-shell-view.tsx +14 -4
- package/src/ui/editor-surface-controller.tsx +5 -3
- package/src/ui/headless/selection-tool-resolver.ts +1 -2
- package/src/ui/presence-overlay-lane.ts +0 -1
- package/src/ui/ui-controller-factory.ts +7 -0
- package/src/ui-tailwind/chrome/build-context-menu-entries.ts +5 -1
- package/src/ui-tailwind/chrome/editor-action-registry.ts +105 -5
- package/src/ui-tailwind/chrome/editor-actions-to-palette.ts +7 -0
- package/src/ui-tailwind/chrome/layer-debug-contracts.ts +208 -0
- package/src/ui-tailwind/chrome/resolve-target-kind.ts +13 -0
- package/src/ui-tailwind/chrome/tw-alert-banner.tsx +11 -3
- package/src/ui-tailwind/chrome/tw-command-palette.tsx +36 -6
- package/src/ui-tailwind/chrome/tw-context-menu.tsx +6 -1
- package/src/ui-tailwind/chrome/tw-display-mode-selector.tsx +42 -109
- package/src/ui-tailwind/chrome/tw-inline-find-bar.tsx +26 -6
- package/src/ui-tailwind/chrome/tw-navigation-command-bar.tsx +328 -0
- package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +8 -4
- package/src/ui-tailwind/chrome/tw-runtime-repl-dialog.tsx +129 -1
- package/src/ui-tailwind/chrome/tw-selection-tool-host.tsx +19 -5
- package/src/ui-tailwind/chrome/tw-selection-tool-structure.tsx +5 -1
- package/src/ui-tailwind/chrome/tw-workspace-chrome-host.tsx +28 -12
- package/src/ui-tailwind/chrome-overlay/tw-chrome-overlay.tsx +30 -3
- package/src/ui-tailwind/chrome-overlay/tw-object-selection-overlay.tsx +116 -10
- package/src/ui-tailwind/chrome-overlay/tw-page-stack-overlay-layer.tsx +223 -94
- package/src/ui-tailwind/chrome-overlay/tw-presence-overlay-lane.tsx +157 -0
- package/src/ui-tailwind/chrome-overlay/tw-review-overlay-lane-markers.tsx +259 -0
- package/src/ui-tailwind/chrome-overlay/tw-scope-card-layer.tsx +5 -2
- package/src/ui-tailwind/chrome-overlay/tw-substrate-overlay-lanes.tsx +314 -0
- package/src/ui-tailwind/debug/README.md +4 -1
- package/src/ui-tailwind/debug/layer11-consumer-readiness.ts +272 -0
- package/src/ui-tailwind/debug/layer11-word-field-matrix-evidence.ts +160 -0
- package/src/ui-tailwind/editor-surface/perf-probe.ts +14 -215
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +42 -0
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +38 -2
- package/src/ui-tailwind/editor-surface/pm-schema.ts +14 -4
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +34 -5
- package/src/ui-tailwind/editor-surface/runtime-decoration-plugin.ts +9 -19
- package/src/ui-tailwind/editor-surface/surface-build-keys.ts +2 -2
- package/src/ui-tailwind/editor-surface/tw-page-block-view.helpers.ts +145 -0
- package/src/ui-tailwind/editor-surface/tw-page-block-view.tsx +16 -11
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +8 -10
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +3 -0
- package/src/ui-tailwind/page-stack/tw-page-chrome-entry.tsx +4 -2
- package/src/ui-tailwind/page-stack/tw-page-stack-chrome-layer.tsx +60 -20
- package/src/ui-tailwind/page-stack/tw-region-block-renderer.tsx +16 -11
- package/src/ui-tailwind/review/tw-health-panel.tsx +36 -17
- package/src/ui-tailwind/review/tw-review-rail.tsx +7 -4
- package/src/ui-tailwind/review-workspace/diagnostics-visibility.ts +44 -0
- package/src/ui-tailwind/review-workspace/page-shell-metrics.ts +11 -0
- package/src/ui-tailwind/review-workspace/tw-review-workspace-rail.tsx +16 -1
- package/src/ui-tailwind/review-workspace/types.ts +26 -12
- package/src/ui-tailwind/review-workspace/use-diagnostics-signal.ts +40 -11
- package/src/ui-tailwind/review-workspace/use-layout-facet-render-signal.ts +2 -1
- package/src/ui-tailwind/review-workspace/use-page-markers.ts +15 -26
- package/src/ui-tailwind/review-workspace/use-scope-card-state.ts +35 -18
- package/src/ui-tailwind/review-workspace/use-selection-toolbar-placement.ts +41 -32
- package/src/ui-tailwind/review-workspace/use-status-bar-page-facts.ts +2 -1
- package/src/ui-tailwind/review-workspace/use-workspace-side-effects.ts +2 -1
- package/src/ui-tailwind/status/tw-status-bar.tsx +6 -5
- package/src/ui-tailwind/toolbar/tw-role-action-region.tsx +52 -80
- package/src/ui-tailwind/toolbar/tw-shell-header.tsx +12 -48
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +9 -4
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +328 -361
- package/src/ui-tailwind/tw-review-workspace.tsx +152 -286
|
@@ -5,10 +5,16 @@
|
|
|
5
5
|
* `load` (partial — runtime pre-load is the caller's responsibility; v3
|
|
6
6
|
* exposes a re-mount semantic later), `getMode` / `setMode` (live;
|
|
7
7
|
* delegates to the runtime view-state posture), `export` (live; delegates
|
|
8
|
-
* to `runtime.exportDocx`), `validate`
|
|
8
|
+
* to `runtime.exportDocx`), `validate` / `getExportSafety`
|
|
9
|
+
* (live-with-adapter reads).
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
|
-
import type {
|
|
12
|
+
import type {
|
|
13
|
+
RuntimeApiHandle,
|
|
14
|
+
RuntimeWordFieldMatrixArtifact,
|
|
15
|
+
RuntimeWordFieldMatrixComparisonLane,
|
|
16
|
+
RuntimeWordFieldMatrixRow,
|
|
17
|
+
} from "../_runtime-handle.ts";
|
|
12
18
|
import type {
|
|
13
19
|
DocumentMode,
|
|
14
20
|
EditorError,
|
|
@@ -163,6 +169,99 @@ export interface ValidateResult {
|
|
|
163
169
|
readonly __mock?: true;
|
|
164
170
|
}
|
|
165
171
|
|
|
172
|
+
interface CompatibilityReadModel {
|
|
173
|
+
readonly reportVersion?: "compatibility-report/1";
|
|
174
|
+
readonly blockExport?: boolean;
|
|
175
|
+
readonly blockExportReasons?: readonly string[];
|
|
176
|
+
readonly warningCount?: number;
|
|
177
|
+
readonly errorCount?: number;
|
|
178
|
+
readonly featureEntries?: ReadonlyArray<unknown>;
|
|
179
|
+
readonly warnings?: ReadonlyArray<unknown>;
|
|
180
|
+
readonly errors?: ReadonlyArray<unknown>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface InteractionGuardReadModel {
|
|
184
|
+
readonly mode?: string;
|
|
185
|
+
readonly readOnly?: boolean;
|
|
186
|
+
readonly effectiveMode?: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
190
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function hasOptionalBoolean(record: Record<string, unknown>, key: string): boolean {
|
|
194
|
+
return record[key] === undefined || typeof record[key] === "boolean";
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function hasOptionalNumber(record: Record<string, unknown>, key: string): boolean {
|
|
198
|
+
return record[key] === undefined || typeof record[key] === "number";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function hasOptionalArray(record: Record<string, unknown>, key: string): boolean {
|
|
202
|
+
return record[key] === undefined || Array.isArray(record[key]);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function isCompatibilityReadModel(value: unknown): value is CompatibilityReadModel {
|
|
206
|
+
if (!isRecord(value)) return false;
|
|
207
|
+
if (
|
|
208
|
+
value.reportVersion !== undefined &&
|
|
209
|
+
value.reportVersion !== "compatibility-report/1"
|
|
210
|
+
) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return (
|
|
214
|
+
hasOptionalBoolean(value, "blockExport") &&
|
|
215
|
+
hasOptionalArray(value, "blockExportReasons") &&
|
|
216
|
+
hasOptionalNumber(value, "warningCount") &&
|
|
217
|
+
hasOptionalNumber(value, "errorCount") &&
|
|
218
|
+
hasOptionalArray(value, "featureEntries") &&
|
|
219
|
+
hasOptionalArray(value, "warnings") &&
|
|
220
|
+
hasOptionalArray(value, "errors")
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface ExportSafetyCitation {
|
|
225
|
+
readonly citationId: string;
|
|
226
|
+
readonly source:
|
|
227
|
+
| "compatibility-report"
|
|
228
|
+
| "compatibility-error"
|
|
229
|
+
| "compatibility-warning"
|
|
230
|
+
| "runtime-warning"
|
|
231
|
+
| "interaction-guard"
|
|
232
|
+
| "render-snapshot";
|
|
233
|
+
readonly path: string;
|
|
234
|
+
readonly code: string;
|
|
235
|
+
readonly message: string;
|
|
236
|
+
readonly blocksExport: boolean;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface ExportSafetyResult {
|
|
240
|
+
readonly validation: {
|
|
241
|
+
readonly reportVersion: "compatibility-report/1";
|
|
242
|
+
readonly blockExport: boolean;
|
|
243
|
+
readonly warningCount: number;
|
|
244
|
+
readonly errorCount: number;
|
|
245
|
+
readonly featureEntriesCount: number;
|
|
246
|
+
};
|
|
247
|
+
readonly exportSafety: {
|
|
248
|
+
readonly canExport: boolean;
|
|
249
|
+
readonly blockedBy: readonly string[];
|
|
250
|
+
readonly blockExportReasons: readonly string[];
|
|
251
|
+
readonly citations: readonly ExportSafetyCitation[];
|
|
252
|
+
};
|
|
253
|
+
readonly mutationState: {
|
|
254
|
+
readonly documentMode: string;
|
|
255
|
+
readonly readOnly: boolean;
|
|
256
|
+
readonly mutationSuccessImpliesExportSafety: false;
|
|
257
|
+
};
|
|
258
|
+
readonly interactionGuard: {
|
|
259
|
+
readonly mode: string;
|
|
260
|
+
readonly readOnly: boolean;
|
|
261
|
+
};
|
|
262
|
+
readonly __mock?: true;
|
|
263
|
+
}
|
|
264
|
+
|
|
166
265
|
export const validateMetadata: ApiV3FnMetadata = {
|
|
167
266
|
name: "runtime.document.validate",
|
|
168
267
|
status: "live-with-adapter",
|
|
@@ -185,6 +284,358 @@ export const validateMetadata: ApiV3FnMetadata = {
|
|
|
185
284
|
"§Runtime API § runtime.document.validate. Adapter composes three shipped runtime reads — getCompatibilityReport() + getWarnings() + getInteractionGuardSnapshot() — into one bundled ValidateResult. Promotes to `live` when a first-class runtime.validate() lands.",
|
|
186
285
|
};
|
|
187
286
|
|
|
287
|
+
export const getExportSafetyMetadata: ApiV3FnMetadata = {
|
|
288
|
+
name: "runtime.document.getExportSafety",
|
|
289
|
+
status: "live-with-adapter",
|
|
290
|
+
sourceLayer: "package-session",
|
|
291
|
+
liveEvidence: {
|
|
292
|
+
runnerTest: "test/api/v3/behavioral-coverage.test.ts",
|
|
293
|
+
commit: "refactor-07-export-safety-read",
|
|
294
|
+
},
|
|
295
|
+
mockShape: {
|
|
296
|
+
deterministic: true,
|
|
297
|
+
seededFrom: "hash",
|
|
298
|
+
shapeDescription:
|
|
299
|
+
"Fallback ExportSafetyResult with zeroed validation counts and canExport=true when compatibility and guard reads are both unavailable.",
|
|
300
|
+
carriesMockFlag: true,
|
|
301
|
+
},
|
|
302
|
+
uxIntent: { uiVisible: false, expectsUxResponse: "none" },
|
|
303
|
+
agentMetadata: {
|
|
304
|
+
readOrMutate: "read",
|
|
305
|
+
boundedScope: "document",
|
|
306
|
+
auditCategory: "document-export-safety",
|
|
307
|
+
},
|
|
308
|
+
stateClass: "A-canonical",
|
|
309
|
+
persistsTo: "canonical",
|
|
310
|
+
rwdReference:
|
|
311
|
+
"§Runtime API § runtime.document.getExportSafety. Adapter composes getCompatibilityReport() + getRenderSnapshot().compatibility + getWarnings() + getInteractionGuardSnapshot() into distinct validation/exportSafety/mutationState sections plus citation rows for blockers and warnings, so callers do not infer export readiness from mutation success or from runtime.document.validate alone.",
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export interface WordFieldMatrixResult {
|
|
315
|
+
readonly schemaVersion: "pe2-word-field-matrix/v0";
|
|
316
|
+
readonly artifactKind: "pe2.word-field-matrix";
|
|
317
|
+
readonly status: "available" | "unavailable";
|
|
318
|
+
readonly source: "debug-word-field-matrix" | "debug-word-field-matrix-unavailable";
|
|
319
|
+
readonly reason?: "provider-unavailable" | "artifact-unavailable";
|
|
320
|
+
readonly doc?: RuntimeWordFieldMatrixArtifact["doc"];
|
|
321
|
+
readonly generatedAtUtc?: string;
|
|
322
|
+
readonly word?: RuntimeWordFieldMatrixArtifact["word"];
|
|
323
|
+
readonly summary: RuntimeWordFieldMatrixArtifact["summary"];
|
|
324
|
+
readonly rows: readonly RuntimeWordFieldMatrixRow[];
|
|
325
|
+
readonly __mock?: true;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export const getWordFieldMatrixMetadata: ApiV3FnMetadata = {
|
|
329
|
+
name: "runtime.document.getWordFieldMatrix",
|
|
330
|
+
status: "live-with-adapter",
|
|
331
|
+
sourceLayer: "runtime-core",
|
|
332
|
+
liveEvidence: {
|
|
333
|
+
runnerTest: "test/api/v3/create-accepts-handle.test.ts",
|
|
334
|
+
commit: "refactor-07-word-field-matrix-readback",
|
|
335
|
+
},
|
|
336
|
+
mockShape: {
|
|
337
|
+
deterministic: true,
|
|
338
|
+
seededFrom: "fixed",
|
|
339
|
+
shapeDescription:
|
|
340
|
+
"Unavailable pe2.word-field-matrix envelope when no debug evidence provider is wired on the RuntimeApiHandle.",
|
|
341
|
+
carriesMockFlag: true,
|
|
342
|
+
},
|
|
343
|
+
uxIntent: { uiVisible: false, expectsUxResponse: "none" },
|
|
344
|
+
agentMetadata: {
|
|
345
|
+
readOrMutate: "read",
|
|
346
|
+
boundedScope: "document",
|
|
347
|
+
auditCategory: "word-field-matrix",
|
|
348
|
+
contextPromptShape:
|
|
349
|
+
"Word-first PE2 field matrix rows with owning layer, Word status, comparison lanes, and routing note.",
|
|
350
|
+
},
|
|
351
|
+
stateClass: "A-canonical",
|
|
352
|
+
persistsTo: "canonical",
|
|
353
|
+
rwdReference:
|
|
354
|
+
"§Runtime API § runtime.document.getWordFieldMatrix. Optional host-wired readback of debug `pe2.word-field-matrix` evidence. Returns plain row/status/provenance values only; product runtime does not synthesize Word COM evidence or route VM runner data.",
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const WORD_FIELD_MATRIX_OWNER_ZEROES = {
|
|
358
|
+
L01: 0,
|
|
359
|
+
L02: 0,
|
|
360
|
+
L03: 0,
|
|
361
|
+
L04: 0,
|
|
362
|
+
L05: 0,
|
|
363
|
+
L06: 0,
|
|
364
|
+
L08: 0,
|
|
365
|
+
L11: 0,
|
|
366
|
+
} as const;
|
|
367
|
+
|
|
368
|
+
const WORD_FIELD_MATRIX_GROUP_ZEROES = {
|
|
369
|
+
structuralSummary: 0,
|
|
370
|
+
pageGeometry: 0,
|
|
371
|
+
tableContinuations: 0,
|
|
372
|
+
fields: 0,
|
|
373
|
+
legalNumberingSamples: 0,
|
|
374
|
+
anchorsAndObjects: 0,
|
|
375
|
+
packagePreservation: 0,
|
|
376
|
+
reviewMarkup: 0,
|
|
377
|
+
} as const;
|
|
378
|
+
|
|
379
|
+
function copyWordFieldComparisonLane(
|
|
380
|
+
lane: RuntimeWordFieldMatrixComparisonLane,
|
|
381
|
+
): RuntimeWordFieldMatrixComparisonLane {
|
|
382
|
+
return {
|
|
383
|
+
status: lane.status,
|
|
384
|
+
...(lane.evidencePath ? { evidencePath: lane.evidencePath } : {}),
|
|
385
|
+
...(lane.note ? { note: lane.note } : {}),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function copyWordFieldMatrixRow(row: RuntimeWordFieldMatrixRow): RuntimeWordFieldMatrixRow {
|
|
390
|
+
return {
|
|
391
|
+
group: row.group,
|
|
392
|
+
field: row.field,
|
|
393
|
+
primaryOwner: row.primaryOwner,
|
|
394
|
+
wordStatus: row.wordStatus,
|
|
395
|
+
wordEvidencePath: row.wordEvidencePath,
|
|
396
|
+
comparison: {
|
|
397
|
+
...(row.comparison.libreOffice
|
|
398
|
+
? { libreOffice: copyWordFieldComparisonLane(row.comparison.libreOffice) }
|
|
399
|
+
: {}),
|
|
400
|
+
...(row.comparison.sourcePackage
|
|
401
|
+
? { sourcePackage: copyWordFieldComparisonLane(row.comparison.sourcePackage) }
|
|
402
|
+
: {}),
|
|
403
|
+
...(row.comparison.graphPdf
|
|
404
|
+
? { graphPdf: copyWordFieldComparisonLane(row.comparison.graphPdf) }
|
|
405
|
+
: {}),
|
|
406
|
+
},
|
|
407
|
+
routingNote: row.routingNote,
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function unavailableWordFieldMatrix(reason: "provider-unavailable" | "artifact-unavailable") {
|
|
412
|
+
return mockPayload(reason, "WordFieldMatrixResult", {
|
|
413
|
+
schemaVersion: "pe2-word-field-matrix/v0" as const,
|
|
414
|
+
artifactKind: "pe2.word-field-matrix" as const,
|
|
415
|
+
status: "unavailable" as const,
|
|
416
|
+
source: "debug-word-field-matrix-unavailable" as const,
|
|
417
|
+
reason,
|
|
418
|
+
summary: {
|
|
419
|
+
rowCount: 0,
|
|
420
|
+
available: 0,
|
|
421
|
+
partial: 0,
|
|
422
|
+
missing: 0,
|
|
423
|
+
byOwner: WORD_FIELD_MATRIX_OWNER_ZEROES,
|
|
424
|
+
byGroup: WORD_FIELD_MATRIX_GROUP_ZEROES,
|
|
425
|
+
},
|
|
426
|
+
rows: [] as readonly RuntimeWordFieldMatrixRow[],
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function projectWordFieldMatrix(
|
|
431
|
+
artifact: RuntimeWordFieldMatrixArtifact,
|
|
432
|
+
): WordFieldMatrixResult {
|
|
433
|
+
return {
|
|
434
|
+
schemaVersion: artifact.schemaVersion,
|
|
435
|
+
artifactKind: artifact.artifactKind,
|
|
436
|
+
status: "available",
|
|
437
|
+
source: "debug-word-field-matrix",
|
|
438
|
+
doc: {
|
|
439
|
+
docId: artifact.doc.docId,
|
|
440
|
+
corpusLane: artifact.doc.corpusLane,
|
|
441
|
+
...(artifact.doc.sourceSha256 ? { sourceSha256: artifact.doc.sourceSha256 } : {}),
|
|
442
|
+
},
|
|
443
|
+
generatedAtUtc: artifact.generatedAtUtc,
|
|
444
|
+
word: {
|
|
445
|
+
status: artifact.word.status,
|
|
446
|
+
...(artifact.word.oracleName ? { oracleName: artifact.word.oracleName } : {}),
|
|
447
|
+
...(artifact.word.backend ? { backend: artifact.word.backend } : {}),
|
|
448
|
+
...(artifact.word.recordPath ? { recordPath: artifact.word.recordPath } : {}),
|
|
449
|
+
...(artifact.word.unavailableReason
|
|
450
|
+
? { unavailableReason: artifact.word.unavailableReason }
|
|
451
|
+
: {}),
|
|
452
|
+
},
|
|
453
|
+
summary: {
|
|
454
|
+
rowCount: artifact.summary.rowCount,
|
|
455
|
+
available: artifact.summary.available,
|
|
456
|
+
partial: artifact.summary.partial,
|
|
457
|
+
missing: artifact.summary.missing,
|
|
458
|
+
byOwner: { ...artifact.summary.byOwner },
|
|
459
|
+
byGroup: { ...artifact.summary.byGroup },
|
|
460
|
+
},
|
|
461
|
+
rows: artifact.rows.map(copyWordFieldMatrixRow),
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function readCompatibilitySnapshot(runtime: RuntimeApiHandle): {
|
|
466
|
+
readonly compatibility: CompatibilityReadModel | null;
|
|
467
|
+
readonly warnings: ReadonlyArray<unknown>;
|
|
468
|
+
readonly guard: InteractionGuardReadModel | null;
|
|
469
|
+
readonly documentMode: string;
|
|
470
|
+
readonly readOnly: boolean;
|
|
471
|
+
} {
|
|
472
|
+
const reportValue = runtime.getCompatibilityReport();
|
|
473
|
+
const report: CompatibilityReadModel | null = isCompatibilityReadModel(reportValue)
|
|
474
|
+
? reportValue
|
|
475
|
+
: null;
|
|
476
|
+
const snapshot = runtime.getRenderSnapshot();
|
|
477
|
+
const snapshotCompatValue: unknown = snapshot.compatibility;
|
|
478
|
+
const snapshotCompat: CompatibilityReadModel | null = isCompatibilityReadModel(snapshotCompatValue)
|
|
479
|
+
? snapshotCompatValue
|
|
480
|
+
: null;
|
|
481
|
+
const guard = runtime.getInteractionGuardSnapshot() as InteractionGuardReadModel | undefined | null;
|
|
482
|
+
const compatibility: CompatibilityReadModel | null = report
|
|
483
|
+
? {
|
|
484
|
+
...snapshotCompat,
|
|
485
|
+
...report,
|
|
486
|
+
blockExportReasons: report.blockExportReasons ?? snapshotCompat?.blockExportReasons,
|
|
487
|
+
}
|
|
488
|
+
: snapshotCompat ?? null;
|
|
489
|
+
return {
|
|
490
|
+
compatibility,
|
|
491
|
+
warnings: runtime.getWarnings(),
|
|
492
|
+
guard: guard ?? null,
|
|
493
|
+
documentMode: snapshot.documentMode ?? "unknown",
|
|
494
|
+
readOnly: snapshot.readOnly ?? guard?.readOnly ?? false,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function countWarnings(
|
|
499
|
+
compatibility: CompatibilityReadModel | null,
|
|
500
|
+
runtimeWarnings: ReadonlyArray<unknown>,
|
|
501
|
+
): number {
|
|
502
|
+
const compatCount = typeof compatibility?.warningCount === "number"
|
|
503
|
+
? compatibility.warningCount
|
|
504
|
+
: compatibility?.warnings?.length ?? 0;
|
|
505
|
+
return compatCount + runtimeWarnings.length;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function countErrors(compatibility: CompatibilityReadModel | null): number {
|
|
509
|
+
return typeof compatibility?.errorCount === "number"
|
|
510
|
+
? compatibility.errorCount
|
|
511
|
+
: compatibility?.errors?.length ?? 0;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function asIssue(value: unknown): { readonly code?: string; readonly message?: string } {
|
|
515
|
+
return value && typeof value === "object"
|
|
516
|
+
? value as { readonly code?: string; readonly message?: string }
|
|
517
|
+
: {};
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function buildExportSafetyCitations(
|
|
521
|
+
compatibility: CompatibilityReadModel | null,
|
|
522
|
+
runtimeWarnings: ReadonlyArray<unknown>,
|
|
523
|
+
guard: InteractionGuardReadModel | null,
|
|
524
|
+
blockExportReasons: readonly string[],
|
|
525
|
+
): readonly ExportSafetyCitation[] {
|
|
526
|
+
const citations: ExportSafetyCitation[] = [];
|
|
527
|
+
|
|
528
|
+
for (let index = 0; index < blockExportReasons.length; index += 1) {
|
|
529
|
+
const reason = blockExportReasons[index];
|
|
530
|
+
citations.push({
|
|
531
|
+
citationId: `export-safety:block-export-reason:${index}`,
|
|
532
|
+
source: "compatibility-report",
|
|
533
|
+
path: `compatibility.blockExportReasons[${index}]`,
|
|
534
|
+
code: "compatibility:block-export",
|
|
535
|
+
message: reason,
|
|
536
|
+
blocksExport: true,
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
for (let index = 0; index < (compatibility?.errors?.length ?? 0); index += 1) {
|
|
541
|
+
const issue = asIssue(compatibility?.errors?.[index]);
|
|
542
|
+
citations.push({
|
|
543
|
+
citationId: `export-safety:compatibility-error:${index}`,
|
|
544
|
+
source: "compatibility-error",
|
|
545
|
+
path: `compatibility.errors[${index}]`,
|
|
546
|
+
code: issue.code ?? "validation:errors",
|
|
547
|
+
message: issue.message ?? "Compatibility validation error blocks export.",
|
|
548
|
+
blocksExport: true,
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
for (let index = 0; index < (compatibility?.warnings?.length ?? 0); index += 1) {
|
|
553
|
+
const issue = asIssue(compatibility?.warnings?.[index]);
|
|
554
|
+
citations.push({
|
|
555
|
+
citationId: `export-safety:compatibility-warning:${index}`,
|
|
556
|
+
source: "compatibility-warning",
|
|
557
|
+
path: `compatibility.warnings[${index}]`,
|
|
558
|
+
code: issue.code ?? "validation:warning",
|
|
559
|
+
message: issue.message ?? "Compatibility validation warning.",
|
|
560
|
+
blocksExport: false,
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
for (let index = 0; index < runtimeWarnings.length; index += 1) {
|
|
565
|
+
const warning = asIssue(runtimeWarnings[index]);
|
|
566
|
+
citations.push({
|
|
567
|
+
citationId: `export-safety:runtime-warning:${index}`,
|
|
568
|
+
source: "runtime-warning",
|
|
569
|
+
path: `runtime.warnings[${index}]`,
|
|
570
|
+
code: warning.code ?? "runtime:warning",
|
|
571
|
+
message: warning.message ?? "Runtime warning.",
|
|
572
|
+
blocksExport: false,
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
if (guard?.readOnly === true) {
|
|
577
|
+
citations.push({
|
|
578
|
+
citationId: "export-safety:interaction-guard:read-only",
|
|
579
|
+
source: "interaction-guard",
|
|
580
|
+
path: "interactionGuard.readOnly",
|
|
581
|
+
code: "interaction-guard:read-only",
|
|
582
|
+
message: "The current interaction guard is read-only; mutation success is not proof of export readiness.",
|
|
583
|
+
blocksExport: false,
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
return citations;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function buildExportSafetyResult(
|
|
591
|
+
runtime: RuntimeApiHandle,
|
|
592
|
+
): (ExportSafetyResult & Partial<MockPayload>) | null {
|
|
593
|
+
const { compatibility, warnings, guard, documentMode, readOnly } =
|
|
594
|
+
readCompatibilitySnapshot(runtime);
|
|
595
|
+
if (!compatibility && !guard) return null;
|
|
596
|
+
|
|
597
|
+
const blockExport = compatibility?.blockExport ?? false;
|
|
598
|
+
const warningCount = countWarnings(compatibility, warnings);
|
|
599
|
+
const errorCount = countErrors(compatibility);
|
|
600
|
+
const featureEntriesCount = compatibility?.featureEntries?.length ?? 0;
|
|
601
|
+
const blockExportReasons = compatibility?.blockExportReasons ?? [];
|
|
602
|
+
const blockedBy = [
|
|
603
|
+
...(blockExport ? ["compatibility:block-export"] : []),
|
|
604
|
+
...(errorCount > 0 ? ["validation:errors"] : []),
|
|
605
|
+
];
|
|
606
|
+
const citations = buildExportSafetyCitations(
|
|
607
|
+
compatibility,
|
|
608
|
+
warnings,
|
|
609
|
+
guard,
|
|
610
|
+
blockExportReasons,
|
|
611
|
+
);
|
|
612
|
+
|
|
613
|
+
return {
|
|
614
|
+
validation: {
|
|
615
|
+
reportVersion: "compatibility-report/1",
|
|
616
|
+
blockExport,
|
|
617
|
+
warningCount,
|
|
618
|
+
errorCount,
|
|
619
|
+
featureEntriesCount,
|
|
620
|
+
},
|
|
621
|
+
exportSafety: {
|
|
622
|
+
canExport: blockedBy.length === 0,
|
|
623
|
+
blockedBy,
|
|
624
|
+
blockExportReasons,
|
|
625
|
+
citations,
|
|
626
|
+
},
|
|
627
|
+
mutationState: {
|
|
628
|
+
documentMode,
|
|
629
|
+
readOnly,
|
|
630
|
+
mutationSuccessImpliesExportSafety: false,
|
|
631
|
+
},
|
|
632
|
+
interactionGuard: {
|
|
633
|
+
mode: guard?.mode ?? guard?.effectiveMode ?? "unknown",
|
|
634
|
+
readOnly: guard?.readOnly ?? readOnly,
|
|
635
|
+
},
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
188
639
|
/* ================================================================== */
|
|
189
640
|
/* family factory */
|
|
190
641
|
/* ================================================================== */
|
|
@@ -268,6 +719,52 @@ export function createDocumentFamily(runtime: RuntimeApiHandle) {
|
|
|
268
719
|
return result;
|
|
269
720
|
},
|
|
270
721
|
|
|
722
|
+
getExportSafety(): ExportSafetyResult & Partial<MockPayload> {
|
|
723
|
+
// @endStateApi — live-with-adapter. Separates validation facts from
|
|
724
|
+
// export readiness and from the latest document-mode/mutation posture.
|
|
725
|
+
// This is a read-only preflight: it never calls exportDocx().
|
|
726
|
+
const result = buildExportSafetyResult(runtime);
|
|
727
|
+
if (result) return result;
|
|
728
|
+
return mockPayload(
|
|
729
|
+
"no compatibility report or interaction guard available (pre-mount or test double)",
|
|
730
|
+
"ExportSafetyResult",
|
|
731
|
+
{
|
|
732
|
+
validation: {
|
|
733
|
+
reportVersion: "compatibility-report/1" as const,
|
|
734
|
+
blockExport: false,
|
|
735
|
+
warningCount: 0,
|
|
736
|
+
errorCount: 0,
|
|
737
|
+
featureEntriesCount: 0,
|
|
738
|
+
},
|
|
739
|
+
exportSafety: {
|
|
740
|
+
canExport: true,
|
|
741
|
+
blockedBy: [] as readonly string[],
|
|
742
|
+
blockExportReasons: [] as readonly string[],
|
|
743
|
+
citations: [] as readonly ExportSafetyCitation[],
|
|
744
|
+
},
|
|
745
|
+
mutationState: {
|
|
746
|
+
documentMode: "unknown",
|
|
747
|
+
readOnly: false,
|
|
748
|
+
mutationSuccessImpliesExportSafety: false as const,
|
|
749
|
+
},
|
|
750
|
+
interactionGuard: { mode: "unknown", readOnly: false },
|
|
751
|
+
},
|
|
752
|
+
);
|
|
753
|
+
},
|
|
754
|
+
|
|
755
|
+
getWordFieldMatrix(): WordFieldMatrixResult & Partial<MockPayload> {
|
|
756
|
+
// @endStateApi — live-with-adapter. Projects a host-wired debug
|
|
757
|
+
// `pe2.word-field-matrix` artifact into the runtime API as plain
|
|
758
|
+
// row/status/provenance values. Product runtime does not build,
|
|
759
|
+
// fetch, or refresh Word COM evidence.
|
|
760
|
+
const artifact = runtime.wordFieldMatrix?.getWordFieldMatrix();
|
|
761
|
+
if (!artifact) return unavailableWordFieldMatrix("provider-unavailable");
|
|
762
|
+
if (artifact.artifactKind !== "pe2.word-field-matrix") {
|
|
763
|
+
return unavailableWordFieldMatrix("artifact-unavailable");
|
|
764
|
+
}
|
|
765
|
+
return projectWordFieldMatrix(artifact);
|
|
766
|
+
},
|
|
767
|
+
|
|
271
768
|
validate(): ValidateResult & Partial<MockPayload> {
|
|
272
769
|
// @endStateApi — live-with-adapter. Composes three shipped runtime
|
|
273
770
|
// reads into a bundled ValidateResult:
|
|
@@ -278,22 +775,8 @@ export function createDocumentFamily(runtime: RuntimeApiHandle) {
|
|
|
278
775
|
// Falls back to a mock-flagged shape only when both the compat read
|
|
279
776
|
// and the guard read are unavailable (e.g. pre-mount). The adapter
|
|
280
777
|
// promotes to `live` when a first-class runtime.validate() surfaces.
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
blockExport?: boolean;
|
|
284
|
-
warningCount?: number;
|
|
285
|
-
errorCount?: number;
|
|
286
|
-
featureEntries?: ReadonlyArray<unknown>;
|
|
287
|
-
}
|
|
288
|
-
| undefined
|
|
289
|
-
| null;
|
|
290
|
-
const snapshotCompat = runtime.getRenderSnapshot().compatibility;
|
|
291
|
-
const bundledReport = report ?? snapshotCompat;
|
|
292
|
-
const warnings = runtime.getWarnings();
|
|
293
|
-
const guard = runtime.getInteractionGuardSnapshot() as
|
|
294
|
-
| { mode?: string; readOnly?: boolean }
|
|
295
|
-
| undefined
|
|
296
|
-
| null;
|
|
778
|
+
const { compatibility: bundledReport, warnings, guard } =
|
|
779
|
+
readCompatibilitySnapshot(runtime);
|
|
297
780
|
if (!bundledReport && !guard) {
|
|
298
781
|
const fallback = mockPayload(
|
|
299
782
|
"no compatibility report or interaction guard available (pre-mount or test double)",
|
|
@@ -319,8 +802,8 @@ export function createDocumentFamily(runtime: RuntimeApiHandle) {
|
|
|
319
802
|
const result: ValidateResult = {
|
|
320
803
|
reportVersion: "compatibility-report/1",
|
|
321
804
|
blockExport: bundledReport?.blockExport ?? false,
|
|
322
|
-
warningCount: (bundledReport
|
|
323
|
-
errorCount: bundledReport
|
|
805
|
+
warningCount: countWarnings(bundledReport, warnings),
|
|
806
|
+
errorCount: countErrors(bundledReport),
|
|
324
807
|
featureEntriesCount: bundledReport?.featureEntries?.length ?? 0,
|
|
325
808
|
interactionGuard: {
|
|
326
809
|
mode: guard?.mode ?? "unknown",
|
|
@@ -18,20 +18,28 @@ import type { MockPayload } from "../_layer-metadata.ts";
|
|
|
18
18
|
import type {
|
|
19
19
|
GeometryIndex,
|
|
20
20
|
GeometryIndexCoverage,
|
|
21
|
+
GeometryIndexSlice,
|
|
22
|
+
GeometryPrecision,
|
|
23
|
+
GeometrySourceIdentity,
|
|
24
|
+
GeometrySpace,
|
|
21
25
|
} from "../../../runtime/geometry/index.ts";
|
|
22
26
|
|
|
23
27
|
function createUnavailableGeometryCoverage(): GeometryIndexCoverage {
|
|
24
28
|
return {
|
|
25
29
|
status: "unavailable",
|
|
26
30
|
pageCount: 0,
|
|
31
|
+
pageFrameCompleteness: { complete: 0, partial: 0, absent: 0 },
|
|
27
32
|
regionCount: 0,
|
|
28
33
|
sliceCount: 0,
|
|
29
34
|
lineCount: 0,
|
|
30
35
|
anchorCount: 0,
|
|
31
36
|
hitTargetCount: 0,
|
|
32
37
|
semanticEntryCount: 0,
|
|
38
|
+
pageLocalFieldLedgerCount: 0,
|
|
33
39
|
replacementEnvelopeCount: 0,
|
|
34
40
|
objectHandleCount: 0,
|
|
41
|
+
layoutDivergenceObjectCount: 0,
|
|
42
|
+
splitRowCarryCount: 0,
|
|
35
43
|
precision: { exact: 0, "within-tolerance": 0, heuristic: 0 },
|
|
36
44
|
};
|
|
37
45
|
}
|
|
@@ -121,6 +129,57 @@ export const getGeometryCoverageMetadata: ApiV3FnMetadata = {
|
|
|
121
129
|
"§Runtime API § runtime.geometry.getGeometryCoverage. PE2 lightweight status read over GeometryFacet.getGeometryCoverage(). Always returns a coverage object; unwired/pre-paint states report status:'unavailable' with zero counts so agents and evidence runners can distinguish no geometry from empty geometry.",
|
|
122
130
|
};
|
|
123
131
|
|
|
132
|
+
export interface GetPageSlicesOptions {
|
|
133
|
+
readonly pageIndex?: number;
|
|
134
|
+
readonly pageId?: string;
|
|
135
|
+
readonly regionKind?: GeometryIndexSlice["regionKind"];
|
|
136
|
+
readonly blockId?: string;
|
|
137
|
+
readonly scopeId?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface V3PageSliceRect {
|
|
141
|
+
readonly x: number;
|
|
142
|
+
readonly y: number;
|
|
143
|
+
readonly width: number;
|
|
144
|
+
readonly height: number;
|
|
145
|
+
readonly space: GeometrySpace;
|
|
146
|
+
readonly precision?: GeometryPrecision;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface V3PageSlice {
|
|
150
|
+
readonly sliceId: string;
|
|
151
|
+
readonly pageId: string;
|
|
152
|
+
readonly pageIndex: number;
|
|
153
|
+
readonly regionId: string;
|
|
154
|
+
readonly regionKind: GeometryIndexSlice["regionKind"];
|
|
155
|
+
readonly blockId: string;
|
|
156
|
+
readonly fragmentId: string;
|
|
157
|
+
readonly kind: GeometryIndexSlice["kind"];
|
|
158
|
+
readonly rect: V3PageSliceRect;
|
|
159
|
+
readonly lineIds: readonly string[];
|
|
160
|
+
readonly sourceIdentity?: GeometrySourceIdentity;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const getPageSlicesMetadata: ApiV3FnMetadata = {
|
|
164
|
+
name: "runtime.geometry.getPageSlices",
|
|
165
|
+
status: "live-with-adapter",
|
|
166
|
+
sourceLayer: "geometry-projection",
|
|
167
|
+
liveEvidence: {
|
|
168
|
+
runnerTest: "test/api/v3/geometry-uses-geometry-handle.test.ts",
|
|
169
|
+
commit: "refactor-07-pe2-page-slice-read-surface",
|
|
170
|
+
},
|
|
171
|
+
uxIntent: { uiVisible: false, expectsUxResponse: "none" },
|
|
172
|
+
agentMetadata: {
|
|
173
|
+
readOrMutate: "read",
|
|
174
|
+
boundedScope: "document",
|
|
175
|
+
auditCategory: "geometry-read",
|
|
176
|
+
},
|
|
177
|
+
stateClass: "A-canonical",
|
|
178
|
+
persistsTo: "canonical",
|
|
179
|
+
rwdReference:
|
|
180
|
+
"§Runtime API § runtime.geometry.getPageSlices. PE2 read surface over GeometryFacet.getGeometryIndex().slices. Returns immutable page-local slice values filtered by pageIndex/pageId/regionKind/blockId/sourceIdentity.scopeId, or [] when no geometry index is warm. This is the narrow public page-slice API over the Layer-05 geometry index; callers do not receive raw GeometryIndexSlice references.",
|
|
181
|
+
};
|
|
182
|
+
|
|
124
183
|
/* ================================================================== */
|
|
125
184
|
/* getCaret — Slice-4 caret geometry (Slice X3 of §4 of coord-05) */
|
|
126
185
|
/* ================================================================== */
|
|
@@ -303,6 +362,44 @@ export function createGeometryFamily(runtime: RuntimeApiHandle) {
|
|
|
303
362
|
return geometry?.getGeometryCoverage() ?? createUnavailableGeometryCoverage();
|
|
304
363
|
},
|
|
305
364
|
|
|
365
|
+
getPageSlices(options: GetPageSlicesOptions = {}): readonly V3PageSlice[] {
|
|
366
|
+
// @endStateApi — live-with-adapter. Provides the narrow v3
|
|
367
|
+
// page-slice read surface over L05 GeometryIndex.slices. The
|
|
368
|
+
// adapter clones each value so callers cannot mutate the geometry
|
|
369
|
+
// index retained by the runtime facet.
|
|
370
|
+
const index = geometry?.getGeometryIndex();
|
|
371
|
+
if (!index) return [];
|
|
372
|
+
return index.slices
|
|
373
|
+
.filter((slice) => {
|
|
374
|
+
if (options.pageIndex !== undefined && slice.pageIndex !== options.pageIndex) return false;
|
|
375
|
+
if (options.pageId !== undefined && slice.pageId !== options.pageId) return false;
|
|
376
|
+
if (options.regionKind !== undefined && slice.regionKind !== options.regionKind) return false;
|
|
377
|
+
if (options.blockId !== undefined && slice.blockId !== options.blockId) return false;
|
|
378
|
+
if (options.scopeId !== undefined && slice.sourceIdentity?.scopeId !== options.scopeId) return false;
|
|
379
|
+
return true;
|
|
380
|
+
})
|
|
381
|
+
.map((slice) => ({
|
|
382
|
+
sliceId: slice.sliceId,
|
|
383
|
+
pageId: slice.pageId,
|
|
384
|
+
pageIndex: slice.pageIndex,
|
|
385
|
+
regionId: slice.regionId,
|
|
386
|
+
regionKind: slice.regionKind,
|
|
387
|
+
blockId: slice.blockId,
|
|
388
|
+
fragmentId: slice.fragmentId,
|
|
389
|
+
kind: slice.kind,
|
|
390
|
+
rect: {
|
|
391
|
+
x: slice.rect.leftPx,
|
|
392
|
+
y: slice.rect.topPx,
|
|
393
|
+
width: slice.rect.widthPx,
|
|
394
|
+
height: slice.rect.heightPx,
|
|
395
|
+
space: slice.rect.space,
|
|
396
|
+
...(slice.rect.precision !== undefined ? { precision: slice.rect.precision } : {}),
|
|
397
|
+
},
|
|
398
|
+
lineIds: [...slice.lineIds],
|
|
399
|
+
...(slice.sourceIdentity !== undefined ? { sourceIdentity: { ...slice.sourceIdentity } } : {}),
|
|
400
|
+
}));
|
|
401
|
+
},
|
|
402
|
+
|
|
306
403
|
getBlockRects(blockIds: readonly string[]): ReadonlyArray<BlockRectEntry & Partial<MockPayload>> {
|
|
307
404
|
// @endStateApi — live-with-adapter. Routes directly through the
|
|
308
405
|
// Layer-05 GeometryFacet's `getBlockRects(blockId)`, which walks
|