@grahlnn/comps 0.1.0 → 0.1.2
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
CHANGED
|
@@ -2355,7 +2355,13 @@ function hasUnsupportedPretextMorphFeatures(text, layoutContext) {
|
|
|
2355
2355
|
return false;
|
|
2356
2356
|
}
|
|
2357
2357
|
function shouldProbePretextMorph(text, layoutContext) {
|
|
2358
|
-
|
|
2358
|
+
if (layoutContext.whiteSpace !== "nowrap") {
|
|
2359
|
+
return true;
|
|
2360
|
+
}
|
|
2361
|
+
if (PROBE_COMPLEX_WHITESPACE_RE.test(text)) {
|
|
2362
|
+
return true;
|
|
2363
|
+
}
|
|
2364
|
+
return PROBE_SYSTEM_UI_RE.test(layoutContext.font);
|
|
2359
2365
|
}
|
|
2360
2366
|
function getPretextMorphRenderedText(text, layoutContext) {
|
|
2361
2367
|
if (layoutContext === null) {
|
|
@@ -2383,6 +2389,24 @@ function getPretextMorphStyleSignature(layoutContext) {
|
|
|
2383
2389
|
engineProfile.preferEarlySoftHyphenBreak ? "1" : "0"
|
|
2384
2390
|
].join("\x00");
|
|
2385
2391
|
}
|
|
2392
|
+
function getPretextMorphTrustSignature({
|
|
2393
|
+
renderText,
|
|
2394
|
+
layoutContext,
|
|
2395
|
+
useContentInlineSize
|
|
2396
|
+
}) {
|
|
2397
|
+
if (layoutContext === null) {
|
|
2398
|
+
return null;
|
|
2399
|
+
}
|
|
2400
|
+
const styleSignature = getPretextMorphStyleSignature(layoutContext);
|
|
2401
|
+
if (styleSignature === null) {
|
|
2402
|
+
return null;
|
|
2403
|
+
}
|
|
2404
|
+
let inlineSizeSignature = layoutContext.width.toFixed(2);
|
|
2405
|
+
if (useContentInlineSize) {
|
|
2406
|
+
inlineSizeSignature = "content";
|
|
2407
|
+
}
|
|
2408
|
+
return [styleSignature, inlineSizeSignature, renderText].join("\x00");
|
|
2409
|
+
}
|
|
2386
2410
|
function getPretextMorphMeasurementBackend(text, layoutContext) {
|
|
2387
2411
|
if (layoutContext === null) {
|
|
2388
2412
|
return "dom";
|
|
@@ -3043,12 +3067,16 @@ function readRootOrigin(node) {
|
|
|
3043
3067
|
const rect = node.getBoundingClientRect();
|
|
3044
3068
|
return { left: rect.left, top: rect.top };
|
|
3045
3069
|
}
|
|
3046
|
-
function getTrustedPretextMeasurementBackend(text, layoutContext) {
|
|
3070
|
+
function getTrustedPretextMeasurementBackend(text, renderText, layoutContext, useContentInlineSize) {
|
|
3047
3071
|
const backend = getPretextMorphMeasurementBackend(text, layoutContext);
|
|
3048
3072
|
if (backend !== "probe") {
|
|
3049
3073
|
return backend;
|
|
3050
3074
|
}
|
|
3051
|
-
const signature =
|
|
3075
|
+
const signature = getPretextMorphTrustSignature({
|
|
3076
|
+
renderText,
|
|
3077
|
+
layoutContext,
|
|
3078
|
+
useContentInlineSize
|
|
3079
|
+
});
|
|
3052
3080
|
if (signature === null) {
|
|
3053
3081
|
return "dom";
|
|
3054
3082
|
}
|
|
@@ -3083,7 +3111,7 @@ function createMorphMeasurementRequest({
|
|
|
3083
3111
|
}
|
|
3084
3112
|
const renderText = getPretextMorphRenderedText(text, layoutContext);
|
|
3085
3113
|
const useContentInlineSize = shouldMeasureUsingContentInlineSize(layoutContext, layoutHint);
|
|
3086
|
-
const measurementBackend = getTrustedPretextMeasurementBackend(text, layoutContext);
|
|
3114
|
+
const measurementBackend = getTrustedPretextMeasurementBackend(text, renderText, layoutContext, useContentInlineSize);
|
|
3087
3115
|
let segments = readCachedMorphSegments(renderText);
|
|
3088
3116
|
if (measurementBackend === "pretext") {
|
|
3089
3117
|
segments = EMPTY_SEGMENTS;
|
|
@@ -3101,8 +3129,17 @@ function createMorphMeasurementRequest({
|
|
|
3101
3129
|
domMeasurementKey
|
|
3102
3130
|
};
|
|
3103
3131
|
}
|
|
3104
|
-
function rememberPretextMeasurementTrust(
|
|
3105
|
-
|
|
3132
|
+
function rememberPretextMeasurementTrust({
|
|
3133
|
+
renderText,
|
|
3134
|
+
layoutContext,
|
|
3135
|
+
useContentInlineSize,
|
|
3136
|
+
trusted
|
|
3137
|
+
}) {
|
|
3138
|
+
const signature = getPretextMorphTrustSignature({
|
|
3139
|
+
renderText,
|
|
3140
|
+
layoutContext,
|
|
3141
|
+
useContentInlineSize
|
|
3142
|
+
});
|
|
3106
3143
|
if (signature === null) {
|
|
3107
3144
|
return;
|
|
3108
3145
|
}
|
|
@@ -3166,7 +3203,12 @@ function measureFromNodes({
|
|
|
3166
3203
|
}
|
|
3167
3204
|
if (measurementBackend === "probe" && pretextSnapshot !== null && domSnapshot !== null) {
|
|
3168
3205
|
const trusted = areSnapshotsEquivalentForPretextTrust(pretextSnapshot, domSnapshot);
|
|
3169
|
-
rememberPretextMeasurementTrust(
|
|
3206
|
+
rememberPretextMeasurementTrust({
|
|
3207
|
+
renderText,
|
|
3208
|
+
layoutContext,
|
|
3209
|
+
useContentInlineSize,
|
|
3210
|
+
trusted
|
|
3211
|
+
});
|
|
3170
3212
|
if (trusted) {
|
|
3171
3213
|
return pretextSnapshot;
|
|
3172
3214
|
}
|
|
@@ -3596,7 +3638,10 @@ function getRootStyle(stage, plan, measurement, layoutContext) {
|
|
|
3596
3638
|
width = plan.layoutInlineSizeFrom;
|
|
3597
3639
|
}
|
|
3598
3640
|
}
|
|
3599
|
-
|
|
3641
|
+
let height;
|
|
3642
|
+
if (plan !== null) {
|
|
3643
|
+
height = plan.frameHeight;
|
|
3644
|
+
}
|
|
3600
3645
|
const shouldTransitionWidth = stage === "animate" && plan !== null && !nearlyEqual(plan.layoutInlineSizeFrom, plan.layoutInlineSizeTo);
|
|
3601
3646
|
const style = {
|
|
3602
3647
|
position: "relative",
|
|
@@ -32,6 +32,11 @@ export type PretextMorphSnapshot = {
|
|
|
32
32
|
export declare function clearPretextMorphCaches(): void;
|
|
33
33
|
export declare function getPretextMorphRenderedText(text: string, layoutContext: Pick<PretextMorphLayoutContext, "whiteSpace"> | null): string;
|
|
34
34
|
export declare function getPretextMorphStyleSignature(layoutContext: PretextMorphLayoutContext | null): string | null;
|
|
35
|
+
export declare function getPretextMorphTrustSignature({ renderText, layoutContext, useContentInlineSize, }: {
|
|
36
|
+
renderText: string;
|
|
37
|
+
layoutContext: PretextMorphLayoutContext | null;
|
|
38
|
+
useContentInlineSize: boolean;
|
|
39
|
+
}): string | null;
|
|
35
40
|
export declare function getPretextMorphMeasurementBackend(text: string, layoutContext: PretextMorphLayoutContext | null): PretextMorphMeasurementBackend;
|
|
36
41
|
export declare function canUsePretextMorphFastPath(text: string, layoutContext: PretextMorphLayoutContext | null): boolean;
|
|
37
42
|
export declare function measureMorphSnapshotWithPretext(text: string, layoutContext: PretextMorphLayoutContext): PretextMorphSnapshot;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grahlnn/comps",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "React components from grahlnn/comps.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"build": "bun run build:js && bun run build:types",
|
|
23
23
|
"build:js": "bun build ./index.ts --outdir ./dist --format esm --target browser --external react --external react/jsx-runtime",
|
|
24
24
|
"build:types": "tsc -p tsconfig.build.json",
|
|
25
|
+
"test:vendor-pretext": "bun test vendor-sync/pretext/layout.test.ts",
|
|
25
26
|
"prepublishOnly": "bun run build"
|
|
26
27
|
},
|
|
27
28
|
"publishConfig": {
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
Vendored from `C:\Users\admin\pretext` under the MIT license.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
-
|
|
5
|
-
- `
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
- `src/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
Vendored from `C:\Users\admin\pretext` under the MIT license.
|
|
2
|
+
|
|
3
|
+
Current upstream sync baseline:
|
|
4
|
+
- repo: `@chenglou/pretext`
|
|
5
|
+
- commit: `488d8c6`
|
|
6
|
+
|
|
7
|
+
Upstream runtime files copied here:
|
|
8
|
+
- `src/analysis.ts`
|
|
9
|
+
- `src/bidi.ts`
|
|
10
|
+
- `src/layout.ts`
|
|
11
|
+
- `src/line-break.ts`
|
|
12
|
+
- `src/measurement.ts`
|
|
13
|
+
|
|
14
|
+
Local compatibility patch:
|
|
15
|
+
- `analysis.ts` keeps `export function normalizeWhitespacePreWrap(...)`
|
|
16
|
+
because `torph/src/utils/text-layout/pretextMorph.ts` imports it directly.
|
|
17
|
+
|
|
18
|
+
Vendor sync guardrails live under `vendor-sync/pretext/`:
|
|
19
|
+
- `layout.test.ts`
|
|
20
|
+
- `test-data.ts`
|
|
21
|
+
|
|
22
|
+
Local project code should import through `torph/src/utils/text-layout/pretext.ts`
|
|
23
|
+
instead of importing these vendor files directly, except for the intentional
|
|
24
|
+
internal use in `pretextMorph.ts`.
|