@grahlnn/comps 0.1.8 → 0.1.9
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/index.js +1840 -1148
- package/dist/torph/index.d.ts +2 -1
- package/dist/torph/src/components/Torph.d.ts +3 -112
- package/dist/torph/src/core/dom-measurement.d.ts +42 -0
- package/dist/torph/src/core/finalize-barrier.d.ts +13 -0
- package/dist/torph/src/core/layout-observer.d.ts +8 -0
- package/dist/torph/src/core/math.d.ts +1 -0
- package/dist/torph/src/core/measurement-policy.d.ts +23 -0
- package/dist/torph/src/core/render.d.ts +16 -0
- package/dist/torph/src/core/root-motion-bridge.d.ts +6 -0
- package/dist/torph/src/core/session.d.ts +81 -0
- package/dist/torph/src/core/snapshot.d.ts +3 -0
- package/dist/torph/src/core/types.d.ts +108 -0
- package/dist/torph/src/debug/trace.d.ts +121 -0
- package/package.json +1 -1
package/dist/torph/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { Torph } from "./src/components/Torph";
|
|
2
|
+
export type { TorphProps } from "./src/components/Torph";
|
|
@@ -1,114 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { type PretextMorphMeasurementBackend } from "../utils/text-layout/pretextMorph";
|
|
3
|
-
export type SupportedWhiteSpace = "normal" | "nowrap" | "pre-wrap";
|
|
4
|
-
export type MorphCharacterLayout = {
|
|
5
|
-
glyph: string;
|
|
6
|
-
key: string;
|
|
7
|
-
left: number;
|
|
8
|
-
top: number;
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
};
|
|
12
|
-
export type MorphSnapshot = {
|
|
13
|
-
text: string;
|
|
14
|
-
renderText: string;
|
|
15
|
-
width: number;
|
|
16
|
-
height: number;
|
|
17
|
-
graphemes: MorphCharacterLayout[];
|
|
18
|
-
};
|
|
19
|
-
export type MorphMeasurement = {
|
|
20
|
-
snapshot: MorphSnapshot;
|
|
21
|
-
layoutInlineSize: number;
|
|
22
|
-
reservedInlineSize: number | null;
|
|
23
|
-
flowInlineSize: number | null;
|
|
24
|
-
rootOrigin: {
|
|
25
|
-
left: number;
|
|
26
|
-
top: number;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export type MorphVisualBridge = {
|
|
30
|
-
offsetX: number;
|
|
31
|
-
offsetY: number;
|
|
32
|
-
};
|
|
33
|
-
export type MorphLiveItem = MorphCharacterLayout & {
|
|
34
|
-
kind: "move" | "enter";
|
|
35
|
-
fromLeft: number | null;
|
|
36
|
-
fromTop: number | null;
|
|
37
|
-
};
|
|
38
|
-
export type MorphRenderPlan = {
|
|
39
|
-
frameWidth: number;
|
|
40
|
-
frameHeight: number;
|
|
41
|
-
layoutInlineSizeFrom: number;
|
|
42
|
-
layoutInlineSizeTo: number;
|
|
43
|
-
sourceRenderText: string;
|
|
44
|
-
targetRenderText: string;
|
|
45
|
-
visualBridge: MorphVisualBridge;
|
|
46
|
-
liveItems: MorphLiveItem[];
|
|
47
|
-
exitItems: MorphCharacterLayout[];
|
|
48
|
-
};
|
|
49
|
-
type LayoutContext = {
|
|
50
|
-
display: string;
|
|
51
|
-
direction: string;
|
|
52
|
-
font: string;
|
|
53
|
-
fontFeatureSettings: string;
|
|
54
|
-
fontVariationSettings: string;
|
|
55
|
-
letterSpacingPx: number;
|
|
56
|
-
lineHeightPx: number;
|
|
57
|
-
parentDisplay: string;
|
|
58
|
-
textTransform: string;
|
|
59
|
-
whiteSpace: SupportedWhiteSpace;
|
|
60
|
-
width: number;
|
|
61
|
-
wordSpacingPx: number;
|
|
62
|
-
measurementVersion: number;
|
|
63
|
-
};
|
|
64
|
-
type MorphSegment = {
|
|
65
|
-
glyph: string;
|
|
66
|
-
key: string;
|
|
67
|
-
};
|
|
68
|
-
type MorphStage = "idle" | "prepare" | "animate";
|
|
69
|
-
type GlyphMove = {
|
|
70
|
-
kind: "move";
|
|
71
|
-
from: MorphCharacterLayout;
|
|
72
|
-
to: MorphCharacterLayout;
|
|
73
|
-
};
|
|
74
|
-
type GlyphEnter = {
|
|
75
|
-
kind: "enter";
|
|
76
|
-
to: MorphCharacterLayout;
|
|
77
|
-
};
|
|
78
|
-
type GlyphExit = {
|
|
79
|
-
kind: "exit";
|
|
80
|
-
from: MorphCharacterLayout;
|
|
81
|
-
};
|
|
82
|
-
type GlyphPairing = GlyphMove | GlyphEnter | GlyphExit;
|
|
83
|
-
export declare function needsMeasurementLayer(measurementBackend: PretextMorphMeasurementBackend, renderText: string): boolean;
|
|
84
|
-
export declare function measureMorphSnapshotFromLayer(text: string, renderText: string, segments: readonly MorphSegment[], layer: HTMLElement | null): MorphSnapshot;
|
|
85
|
-
export declare function resolveContentWidthLockInlineSize(layoutHint: MorphMeasurement): number;
|
|
86
|
-
export declare function shouldHealIdleMeasurementFromFlow(measurement: MorphMeasurement, flowLineCount: number | null): boolean;
|
|
87
|
-
export declare function refineMeasurementWithLiveGeometry(measurement: MorphMeasurement, liveGeometry: {
|
|
88
|
-
flowInlineSize: number | null;
|
|
89
|
-
rootOrigin: {
|
|
90
|
-
left: number;
|
|
91
|
-
top: number;
|
|
92
|
-
};
|
|
93
|
-
}): MorphMeasurement;
|
|
94
|
-
export declare function pairMorphCharacters(previous: MorphCharacterLayout[], next: MorphCharacterLayout[]): GlyphPairing[];
|
|
95
|
-
export declare function resolveMorphFrameBounds(previous: MorphSnapshot, next: MorphSnapshot): {
|
|
96
|
-
width: number;
|
|
97
|
-
height: number;
|
|
98
|
-
};
|
|
99
|
-
export declare function buildMorphVisualBridge(previous: MorphMeasurement, next: MorphMeasurement): MorphVisualBridge;
|
|
100
|
-
export declare function buildMorphPlan(previous: MorphMeasurement, next: MorphMeasurement, visualBridge?: MorphVisualBridge): MorphRenderPlan;
|
|
101
|
-
export declare function getLiveTransform(item: MorphLiveItem, stage: MorphStage, visualBridge: MorphVisualBridge): string;
|
|
102
|
-
export declare function getLiveTransition(item: MorphLiveItem, stage: MorphStage): string | undefined;
|
|
103
|
-
export declare function getExitTransform(visualBridge: MorphVisualBridge): string;
|
|
104
|
-
export declare function getExitTransition(stage: MorphStage): string | undefined;
|
|
105
|
-
export declare function supportsIntrinsicWidthLock(display: string, parentDisplay: string): boolean;
|
|
106
|
-
export declare function getRootDisplay(layoutContext: LayoutContext | null): "grid" | "inline-grid";
|
|
107
|
-
export declare function getRootStyle(stage: MorphStage, plan: MorphRenderPlan | null, measurement: MorphMeasurement | null, layoutContext: LayoutContext | null): CSSProperties;
|
|
108
|
-
export declare function getMeasurementLayerStyle(layoutContext: LayoutContext | null, useContentInlineSize?: boolean): CSSProperties;
|
|
109
|
-
export declare function resolveFlowText(committedMeasurement: MorphMeasurement | null, stateMeasurement: MorphMeasurement | null, text: string): string;
|
|
110
|
-
export declare function Torph({ text, className, }: {
|
|
1
|
+
export type TorphProps = {
|
|
111
2
|
text: string;
|
|
112
3
|
className?: string;
|
|
113
|
-
}
|
|
114
|
-
export {};
|
|
4
|
+
};
|
|
5
|
+
export declare function Torph({ text, className, }: TorphProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type PretextMorphMeasurementBackend } from "../utils/text-layout/pretextMorph";
|
|
2
|
+
import { type LayoutContext, type MorphMeasurement, type MorphSegment, type MorphSnapshot } from "./types";
|
|
3
|
+
export type SnapshotDrift = {
|
|
4
|
+
comparedGlyphs: number;
|
|
5
|
+
expectedGlyphs: number;
|
|
6
|
+
actualGlyphs: number;
|
|
7
|
+
maxAbsLeftDelta: number;
|
|
8
|
+
maxAbsTopDelta: number;
|
|
9
|
+
maxAbsWidthDelta: number;
|
|
10
|
+
maxAbsHeightDelta: number;
|
|
11
|
+
snapshotWidthDelta: number;
|
|
12
|
+
snapshotHeightDelta: number;
|
|
13
|
+
mismatches: Array<{
|
|
14
|
+
index: number;
|
|
15
|
+
glyph: string;
|
|
16
|
+
leftDelta: number;
|
|
17
|
+
topDelta: number;
|
|
18
|
+
widthDelta: number;
|
|
19
|
+
heightDelta: number;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
export declare function readCachedMorphSnapshot(cache: Map<string, MorphSnapshot>, cacheKey: string): MorphSnapshot | null;
|
|
23
|
+
export declare function rememberCachedMorphSnapshot(cache: Map<string, MorphSnapshot>, cacheKey: string, snapshot: MorphSnapshot): void;
|
|
24
|
+
export declare function measureMorphSnapshotFromLayer(text: string, renderText: string, segments: readonly MorphSegment[], layer: HTMLElement | null): MorphSnapshot;
|
|
25
|
+
export declare function readRootOrigin(node: HTMLElement): {
|
|
26
|
+
left: number;
|
|
27
|
+
top: number;
|
|
28
|
+
};
|
|
29
|
+
export declare function measureLiveFlowSnapshot(root: HTMLElement, flowTextNode: HTMLSpanElement): MorphSnapshot | null;
|
|
30
|
+
export declare function measureSnapshotDrift(expected: MorphSnapshot, actual: MorphSnapshot): SnapshotDrift;
|
|
31
|
+
export declare function measureOverlayBoxSnapshot(root: HTMLElement, overlayRoot: HTMLElement, role: "live" | "exit"): MorphSnapshot | null;
|
|
32
|
+
export declare function measureFromNodes({ root, layoutContext, layoutHint, layer, measurementBackend, snapshotOverride, text, renderText, segments, }: {
|
|
33
|
+
root: HTMLElement;
|
|
34
|
+
layoutContext: LayoutContext;
|
|
35
|
+
layoutHint: MorphMeasurement | null;
|
|
36
|
+
layer: HTMLElement | null;
|
|
37
|
+
measurementBackend: PretextMorphMeasurementBackend;
|
|
38
|
+
snapshotOverride: MorphSnapshot | null;
|
|
39
|
+
text: string;
|
|
40
|
+
renderText: string;
|
|
41
|
+
segments: readonly MorphSegment[];
|
|
42
|
+
}): MorphMeasurement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type MorphFinalizeSignal = "live-transform";
|
|
2
|
+
export type MorphFinalizeBarrier = {
|
|
3
|
+
waitForLiveTransform: boolean;
|
|
4
|
+
sawLiveTransform: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function createMorphFinalizeBarrier(hasMoveTransitions: boolean): MorphFinalizeBarrier;
|
|
7
|
+
export declare function recordMorphFinalizeSignal(barrier: MorphFinalizeBarrier, signal: MorphFinalizeSignal): MorphFinalizeBarrier;
|
|
8
|
+
export declare function isMorphFinalizeBarrierSatisfied(barrier: MorphFinalizeBarrier): boolean;
|
|
9
|
+
export declare function summarizeMorphFinalizeBarrier(barrier: MorphFinalizeBarrier): {
|
|
10
|
+
waitForLiveTransform: boolean;
|
|
11
|
+
sawLiveTransform: boolean;
|
|
12
|
+
satisfied: boolean;
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LayoutContext } from "./types";
|
|
2
|
+
export declare function readFont(styles: CSSStyleDeclaration): string;
|
|
3
|
+
export declare function notifyMorphMeasurementInvalidationSubscribers(): void;
|
|
4
|
+
export declare function subscribeMorphMeasurementInvalidation(subscriber: () => void): () => void;
|
|
5
|
+
export declare function useObservedLayoutContext<T extends HTMLElement>(deps: readonly unknown[]): {
|
|
6
|
+
ref: import("react").RefObject<T | null>;
|
|
7
|
+
layoutContext: LayoutContext | null;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function nearlyEqual(a: number, b: number, epsilon?: number): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type PretextMorphMeasurementBackend } from "../utils/text-layout/pretextMorph";
|
|
2
|
+
import { type LayoutContext, type MorphMeasurement, type MorphMeasurementRequest, type MorphSegment, type MorphSnapshot } from "./types";
|
|
3
|
+
export declare function clearPretextMorphTrustCache(): void;
|
|
4
|
+
export declare function clearMorphMeasurementCaches(): void;
|
|
5
|
+
export declare function bumpMorphMeasurementEpoch(): void;
|
|
6
|
+
export declare function getMorphMeasurementEpoch(): number;
|
|
7
|
+
export declare function readCachedMorphSegments(text: string): readonly MorphSegment[];
|
|
8
|
+
export declare function shouldMeasureUsingContentInlineSize(layoutContext: LayoutContext, layoutHint: MorphMeasurement | null): boolean;
|
|
9
|
+
export declare function getTrustedPretextMeasurementBackend(text: string, renderText: string, layoutContext: LayoutContext, useContentInlineSize: boolean): PretextMorphMeasurementBackend;
|
|
10
|
+
export declare function needsMeasurementLayer(measurementBackend: PretextMorphMeasurementBackend, renderText: string): boolean;
|
|
11
|
+
export declare function canCacheMeasurementLayerSnapshot(measurementBackend: PretextMorphMeasurementBackend | null): measurementBackend is "dom";
|
|
12
|
+
export declare function createMorphMeasurementRequest({ text, layoutContext, layoutHint, }: {
|
|
13
|
+
text: string;
|
|
14
|
+
layoutContext: LayoutContext | null;
|
|
15
|
+
layoutHint: MorphMeasurement | null;
|
|
16
|
+
}): MorphMeasurementRequest | null;
|
|
17
|
+
export declare function rememberPretextMeasurementTrust({ renderText, layoutContext, useContentInlineSize, trusted, }: {
|
|
18
|
+
renderText: string;
|
|
19
|
+
layoutContext: LayoutContext;
|
|
20
|
+
useContentInlineSize: boolean;
|
|
21
|
+
trusted: boolean;
|
|
22
|
+
}): void;
|
|
23
|
+
export declare function areSnapshotsEquivalentForPretextTrust(left: MorphSnapshot, right: MorphSnapshot): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import { type LayoutContext, type MorphLiveItem, type MorphMeasurement, type MorphRenderPlan, type MorphSnapshot, type MorphStage, type MorphVisualBridge } from "./types";
|
|
3
|
+
export declare function getFadeDuration(fraction: number): number;
|
|
4
|
+
export declare function getOverlayStyle(stage: MorphStage, plan: MorphRenderPlan): CSSProperties;
|
|
5
|
+
export declare function getLiveTransform(item: MorphLiveItem, stage: MorphStage, visualBridge: MorphVisualBridge): string;
|
|
6
|
+
export declare function getLiveTransition(item: MorphLiveItem, stage: MorphStage): string | undefined;
|
|
7
|
+
export declare function getExitTransform(visualBridge: MorphVisualBridge): string;
|
|
8
|
+
export declare function getExitTransition(stage: MorphStage): string | undefined;
|
|
9
|
+
export declare function supportsIntrinsicWidthLock(display: string, parentDisplay: string): boolean;
|
|
10
|
+
export declare function getRootDisplay(layoutContext: LayoutContext | null): "grid" | "inline-grid";
|
|
11
|
+
export declare function getRootStyle(stage: MorphStage, plan: MorphRenderPlan | null, measurement: MorphMeasurement | null, layoutContext: LayoutContext | null): CSSProperties;
|
|
12
|
+
export declare function getMeasurementLayerStyle(layoutContext: LayoutContext | null, useContentInlineSize?: boolean): CSSProperties;
|
|
13
|
+
export declare function resolveFlowText(committedMeasurement: MorphMeasurement | null, stateMeasurement: MorphMeasurement | null, text: string): string;
|
|
14
|
+
export declare function shouldRenderGlyphLayer(stage: MorphStage, plan: MorphRenderPlan | null, measurement: MorphMeasurement | null): boolean;
|
|
15
|
+
export declare function resolveGlyphSliceWhiteSpace(snapshot: MorphSnapshot | null): "inherit" | "nowrap";
|
|
16
|
+
export declare function createSteadyGlyphPlan(measurement: MorphMeasurement): MorphRenderPlan;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type RootMotionBridge = {
|
|
2
|
+
sourceLeft: number;
|
|
3
|
+
settledLeft: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function resolveRootMotionBridgeBaseOffsetX(bridge: RootMotionBridge): number;
|
|
6
|
+
export declare function resolveRootMotionBridgeOverlayOffsetX(bridge: RootMotionBridge, currentLeft: number): number;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
+
import { type MorphCharacterLayout, type MorphMeasurement, type MorphRenderPlan, type MorphSession, type MorphState, type MorphTimeline, type MorphVisualBridge } from "./types";
|
|
3
|
+
type GlyphMove = {
|
|
4
|
+
kind: "move";
|
|
5
|
+
from: MorphCharacterLayout;
|
|
6
|
+
to: MorphCharacterLayout;
|
|
7
|
+
};
|
|
8
|
+
type GlyphEnter = {
|
|
9
|
+
kind: "enter";
|
|
10
|
+
to: MorphCharacterLayout;
|
|
11
|
+
};
|
|
12
|
+
type GlyphExit = {
|
|
13
|
+
kind: "exit";
|
|
14
|
+
from: MorphCharacterLayout;
|
|
15
|
+
};
|
|
16
|
+
type GlyphPairing = GlyphMove | GlyphEnter | GlyphExit;
|
|
17
|
+
export type MorphSessionDecision = {
|
|
18
|
+
kind: "freeze-animating-target";
|
|
19
|
+
target: MorphMeasurement;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "commit-static";
|
|
22
|
+
measurement: MorphMeasurement;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "start-morph";
|
|
25
|
+
source: MorphMeasurement;
|
|
26
|
+
target: MorphMeasurement;
|
|
27
|
+
};
|
|
28
|
+
export declare function pairMorphCharacters(previous: MorphCharacterLayout[], next: MorphCharacterLayout[]): GlyphPairing[];
|
|
29
|
+
export declare function resolveMorphFrameBounds(previous: MorphMeasurement["snapshot"], next: MorphMeasurement["snapshot"]): {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
export declare function buildMorphPlan(previous: MorphMeasurement, next: MorphMeasurement, visualBridge?: MorphVisualBridge): MorphRenderPlan;
|
|
34
|
+
export declare function sameMeasurement(a: MorphMeasurement, b: MorphMeasurement): boolean;
|
|
35
|
+
export declare function selectMorphLayoutHint(session: MorphSession): MorphMeasurement | null;
|
|
36
|
+
export declare function decideMorphSessionUpdate({ committed, target, animating, nextMeasurement, fontsReady, }: {
|
|
37
|
+
committed: MorphMeasurement | null;
|
|
38
|
+
target: MorphMeasurement | null;
|
|
39
|
+
animating: boolean;
|
|
40
|
+
nextMeasurement: MorphMeasurement;
|
|
41
|
+
fontsReady: boolean;
|
|
42
|
+
}): MorphSessionDecision;
|
|
43
|
+
export declare function areFontsReady(): boolean;
|
|
44
|
+
export declare function cancelTimeline(timeline: MorphTimeline): void;
|
|
45
|
+
export declare function resetMorph(session: MorphSession, timeline: MorphTimeline, setState: (state: MorphState) => void): void;
|
|
46
|
+
export declare function commitStaticMeasurement(session: MorphSession, measurement: MorphMeasurement, setState: Dispatch<SetStateAction<MorphState>>): void;
|
|
47
|
+
export declare function applyMorphSessionDecision({ decision, session, timeline, setState, }: {
|
|
48
|
+
decision: MorphSessionDecision;
|
|
49
|
+
session: MorphSession;
|
|
50
|
+
timeline: MorphTimeline;
|
|
51
|
+
setState: Dispatch<SetStateAction<MorphState>>;
|
|
52
|
+
}): MorphMeasurement;
|
|
53
|
+
export declare function reconcileMorphSessionUpdate({ session, timeline, nextMeasurement, fontsReady, setState, }: {
|
|
54
|
+
session: MorphSession;
|
|
55
|
+
timeline: MorphTimeline;
|
|
56
|
+
nextMeasurement: MorphMeasurement;
|
|
57
|
+
fontsReady: boolean;
|
|
58
|
+
setState: Dispatch<SetStateAction<MorphState>>;
|
|
59
|
+
}): MorphMeasurement;
|
|
60
|
+
export declare function finalizeMorphTransition({ session, timeline, measurement, setState, }: {
|
|
61
|
+
session: MorphSession;
|
|
62
|
+
timeline: MorphTimeline;
|
|
63
|
+
measurement: MorphMeasurement;
|
|
64
|
+
setState: Dispatch<SetStateAction<MorphState>>;
|
|
65
|
+
}): void;
|
|
66
|
+
export declare function resolvePreparedMeasurementOrigin(measurement: MorphMeasurement, origin: {
|
|
67
|
+
left: number;
|
|
68
|
+
top: number;
|
|
69
|
+
}): MorphMeasurement;
|
|
70
|
+
export declare function resolvePreparedPlanVisualBridge(plan: MorphRenderPlan, origin: {
|
|
71
|
+
left: number;
|
|
72
|
+
top: number;
|
|
73
|
+
}): MorphRenderPlan;
|
|
74
|
+
export declare function startMorph({ source, target, session, timeline, setState, }: {
|
|
75
|
+
source: MorphMeasurement;
|
|
76
|
+
target: MorphMeasurement;
|
|
77
|
+
session: MorphSession;
|
|
78
|
+
timeline: MorphTimeline;
|
|
79
|
+
setState: Dispatch<SetStateAction<MorphState>>;
|
|
80
|
+
}): void;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { PretextMorphMeasurementBackend } from "../utils/text-layout/pretextMorph";
|
|
2
|
+
export declare const MORPH: {
|
|
3
|
+
readonly durationMs: 280;
|
|
4
|
+
readonly maxFadeMs: 150;
|
|
5
|
+
readonly ease: "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
6
|
+
readonly geometryEpsilon: 0.5;
|
|
7
|
+
readonly contentWidthLockEpsilon: 2;
|
|
8
|
+
readonly lineGroupingEpsilon: 1;
|
|
9
|
+
};
|
|
10
|
+
export type SupportedWhiteSpace = "normal" | "nowrap" | "pre-wrap";
|
|
11
|
+
export type MorphCharacterLayout = {
|
|
12
|
+
glyph: string;
|
|
13
|
+
key: string;
|
|
14
|
+
left: number;
|
|
15
|
+
top: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
export type MorphSnapshot = {
|
|
20
|
+
text: string;
|
|
21
|
+
renderText: string;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
graphemes: MorphCharacterLayout[];
|
|
25
|
+
};
|
|
26
|
+
export type MorphMeasurement = {
|
|
27
|
+
snapshot: MorphSnapshot;
|
|
28
|
+
layoutInlineSize: number;
|
|
29
|
+
reservedInlineSize: number | null;
|
|
30
|
+
flowInlineSize: number | null;
|
|
31
|
+
rootOrigin: {
|
|
32
|
+
left: number;
|
|
33
|
+
top: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type MorphVisualBridge = {
|
|
37
|
+
offsetX: number;
|
|
38
|
+
offsetY: number;
|
|
39
|
+
};
|
|
40
|
+
export type MorphLiveItem = MorphCharacterLayout & {
|
|
41
|
+
kind: "move" | "enter";
|
|
42
|
+
fromLeft: number | null;
|
|
43
|
+
fromTop: number | null;
|
|
44
|
+
};
|
|
45
|
+
export type MorphRenderPlan = {
|
|
46
|
+
frameWidth: number;
|
|
47
|
+
frameHeight: number;
|
|
48
|
+
layoutInlineSizeFrom: number;
|
|
49
|
+
layoutInlineSizeTo: number;
|
|
50
|
+
sourceRenderText: string;
|
|
51
|
+
targetRenderText: string;
|
|
52
|
+
sourceRootOrigin: {
|
|
53
|
+
left: number;
|
|
54
|
+
top: number;
|
|
55
|
+
};
|
|
56
|
+
visualBridge: MorphVisualBridge;
|
|
57
|
+
liveItems: MorphLiveItem[];
|
|
58
|
+
exitItems: MorphCharacterLayout[];
|
|
59
|
+
};
|
|
60
|
+
export type LayoutContext = {
|
|
61
|
+
display: string;
|
|
62
|
+
direction: string;
|
|
63
|
+
font: string;
|
|
64
|
+
fontFeatureSettings: string;
|
|
65
|
+
fontVariationSettings: string;
|
|
66
|
+
letterSpacingPx: number;
|
|
67
|
+
lineHeightPx: number;
|
|
68
|
+
parentDisplay: string;
|
|
69
|
+
textTransform: string;
|
|
70
|
+
whiteSpace: SupportedWhiteSpace;
|
|
71
|
+
width: number;
|
|
72
|
+
wordSpacingPx: number;
|
|
73
|
+
measurementVersion: number;
|
|
74
|
+
};
|
|
75
|
+
export type MorphSegment = {
|
|
76
|
+
glyph: string;
|
|
77
|
+
key: string;
|
|
78
|
+
};
|
|
79
|
+
export type MorphStage = "idle" | "prepare" | "animate";
|
|
80
|
+
export type MorphState = {
|
|
81
|
+
stage: MorphStage;
|
|
82
|
+
measurement: MorphMeasurement | null;
|
|
83
|
+
plan: MorphRenderPlan | null;
|
|
84
|
+
};
|
|
85
|
+
export type MorphSession = {
|
|
86
|
+
committed: MorphMeasurement | null;
|
|
87
|
+
target: MorphMeasurement | null;
|
|
88
|
+
animating: boolean;
|
|
89
|
+
};
|
|
90
|
+
export type MorphTimeline = {
|
|
91
|
+
prepareFrame: number | null;
|
|
92
|
+
animateFrame: number | null;
|
|
93
|
+
finalizeTimer: number | null;
|
|
94
|
+
};
|
|
95
|
+
export type MorphMeasurementRequest = {
|
|
96
|
+
text: string;
|
|
97
|
+
renderText: string;
|
|
98
|
+
segments: readonly MorphSegment[];
|
|
99
|
+
measurementBackend: PretextMorphMeasurementBackend;
|
|
100
|
+
useContentInlineSize: boolean;
|
|
101
|
+
domMeasurementKey: string | null;
|
|
102
|
+
};
|
|
103
|
+
export declare const EMPTY_STATE: MorphState;
|
|
104
|
+
export declare const EMPTY_SESSION: MorphSession;
|
|
105
|
+
export declare const EMPTY_TIMELINE: MorphTimeline;
|
|
106
|
+
export declare const ZERO_BRIDGE: MorphVisualBridge;
|
|
107
|
+
export declare const EMPTY_SEGMENTS: readonly MorphSegment[];
|
|
108
|
+
export declare function resolveContentWidthLockInlineSize(layoutHint: MorphMeasurement): number;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { LayoutContext, MorphMeasurement, MorphSnapshot } from "../core/types";
|
|
2
|
+
export type TorphDebugConfig = boolean | {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
capture?: boolean;
|
|
5
|
+
console?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type TorphTraceApi = {
|
|
8
|
+
clear: () => void;
|
|
9
|
+
count: () => number;
|
|
10
|
+
download: (filename?: string) => string | null;
|
|
11
|
+
text: () => string;
|
|
12
|
+
};
|
|
13
|
+
export type SnapshotDrift = {
|
|
14
|
+
comparedGlyphs: number;
|
|
15
|
+
expectedGlyphs: number;
|
|
16
|
+
actualGlyphs: number;
|
|
17
|
+
maxAbsLeftDelta: number;
|
|
18
|
+
maxAbsTopDelta: number;
|
|
19
|
+
maxAbsWidthDelta: number;
|
|
20
|
+
maxAbsHeightDelta: number;
|
|
21
|
+
snapshotWidthDelta: number;
|
|
22
|
+
snapshotHeightDelta: number;
|
|
23
|
+
mismatches: Array<{
|
|
24
|
+
index: number;
|
|
25
|
+
glyph: string;
|
|
26
|
+
leftDelta: number;
|
|
27
|
+
topDelta: number;
|
|
28
|
+
widthDelta: number;
|
|
29
|
+
heightDelta: number;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
export declare const TORPH_TRACE_SCHEMA_VERSION = 7;
|
|
33
|
+
export declare function nextTorphDebugInstanceId(): number;
|
|
34
|
+
export declare function readTorphDebugConfig(): TorphDebugConfig | null;
|
|
35
|
+
export declare function shouldCaptureTorphTrace(config: TorphDebugConfig | null): boolean;
|
|
36
|
+
export declare function isTorphDebugEnabled(config: TorphDebugConfig | null): boolean;
|
|
37
|
+
export declare function shouldRunTorphInstrumentation(config: TorphDebugConfig | null): boolean;
|
|
38
|
+
export declare function ensureTorphTraceApi(): TorphTraceApi;
|
|
39
|
+
export declare function roundDebugValue(value: number | null | undefined): number | null | undefined;
|
|
40
|
+
export declare function summarizeDebugSnapshot(snapshot: MorphSnapshot | null): {
|
|
41
|
+
text: string;
|
|
42
|
+
renderText: string;
|
|
43
|
+
width: number | null | undefined;
|
|
44
|
+
height: number | null | undefined;
|
|
45
|
+
graphemes: number;
|
|
46
|
+
} | null;
|
|
47
|
+
export declare function summarizeDebugGlyphs(snapshot: MorphSnapshot | null): {
|
|
48
|
+
index: number;
|
|
49
|
+
glyph: string;
|
|
50
|
+
key: string;
|
|
51
|
+
left: number | null | undefined;
|
|
52
|
+
top: number | null | undefined;
|
|
53
|
+
width: number | null | undefined;
|
|
54
|
+
height: number | null | undefined;
|
|
55
|
+
}[] | null;
|
|
56
|
+
export declare function summarizeDebugMeasurement(measurement: MorphMeasurement | null): {
|
|
57
|
+
layoutInlineSize: number | null | undefined;
|
|
58
|
+
reservedInlineSize: number | null | undefined;
|
|
59
|
+
flowInlineSize: number | null | undefined;
|
|
60
|
+
rootOrigin: {
|
|
61
|
+
left: number | null | undefined;
|
|
62
|
+
top: number | null | undefined;
|
|
63
|
+
};
|
|
64
|
+
snapshot: {
|
|
65
|
+
text: string;
|
|
66
|
+
renderText: string;
|
|
67
|
+
width: number | null | undefined;
|
|
68
|
+
height: number | null | undefined;
|
|
69
|
+
graphemes: number;
|
|
70
|
+
} | null;
|
|
71
|
+
} | null;
|
|
72
|
+
export declare function summarizeDebugLayoutContext(layoutContext: LayoutContext | null): {
|
|
73
|
+
display: string;
|
|
74
|
+
parentDisplay: string;
|
|
75
|
+
whiteSpace: import("../core/types").SupportedWhiteSpace;
|
|
76
|
+
width: number | null | undefined;
|
|
77
|
+
measurementVersion: number;
|
|
78
|
+
} | null;
|
|
79
|
+
export declare function summarizeDebugRect(rect: DOMRect | null): {
|
|
80
|
+
left: number | null | undefined;
|
|
81
|
+
top: number | null | undefined;
|
|
82
|
+
width: number | null | undefined;
|
|
83
|
+
height: number | null | undefined;
|
|
84
|
+
} | null;
|
|
85
|
+
export declare function summarizeDebugViewportAnchors(snapshot: MorphSnapshot | null, rootRect: DOMRect | null): {
|
|
86
|
+
index: number;
|
|
87
|
+
glyph: string;
|
|
88
|
+
left: number | null | undefined;
|
|
89
|
+
top: number | null | undefined;
|
|
90
|
+
width: number | null | undefined;
|
|
91
|
+
height: number | null | undefined;
|
|
92
|
+
}[] | null;
|
|
93
|
+
export declare function summarizeDebugRootOriginDrift(measurement: MorphMeasurement | null, rootRect: DOMRect | null): {
|
|
94
|
+
expectedLeft: number | null | undefined;
|
|
95
|
+
expectedTop: number | null | undefined;
|
|
96
|
+
actualLeft: number | null | undefined;
|
|
97
|
+
actualTop: number | null | undefined;
|
|
98
|
+
deltaLeft: number | null | undefined;
|
|
99
|
+
deltaTop: number | null | undefined;
|
|
100
|
+
} | null;
|
|
101
|
+
export declare function summarizeSnapshotDrift(drift: SnapshotDrift): {
|
|
102
|
+
comparedGlyphs: number;
|
|
103
|
+
expectedGlyphs: number;
|
|
104
|
+
actualGlyphs: number;
|
|
105
|
+
snapshotWidthDelta: number | null | undefined;
|
|
106
|
+
snapshotHeightDelta: number | null | undefined;
|
|
107
|
+
maxAbsLeftDelta: number | null | undefined;
|
|
108
|
+
maxAbsTopDelta: number | null | undefined;
|
|
109
|
+
maxAbsWidthDelta: number | null | undefined;
|
|
110
|
+
maxAbsHeightDelta: number | null | undefined;
|
|
111
|
+
mismatches: {
|
|
112
|
+
index: number;
|
|
113
|
+
glyph: string;
|
|
114
|
+
leftDelta: number | null | undefined;
|
|
115
|
+
topDelta: number | null | undefined;
|
|
116
|
+
widthDelta: number | null | undefined;
|
|
117
|
+
heightDelta: number | null | undefined;
|
|
118
|
+
}[];
|
|
119
|
+
};
|
|
120
|
+
export declare function logTorphDebug(instanceId: number, event: string, payload: Record<string, unknown>): void;
|
|
121
|
+
export {};
|