@drskillissue/ganko 0.1.19 → 0.1.20

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.
@@ -33010,6 +33010,7 @@ function readStatefulBaseValueIndex(graph) {
33010
33010
  }
33011
33011
 
33012
33012
  // src/cross-file/layout/context-classification.ts
33013
+ var WHITESPACE_RE4 = /\s+/;
33013
33014
  var TABLE_SEMANTIC_TAGS = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot", "tr", "td", "th"]);
33014
33015
  var TABLE_DISPLAY_VALUES = /* @__PURE__ */ new Set([
33015
33016
  "table",
@@ -33048,6 +33049,7 @@ function createAlignmentContextForParent(parent, snapshot) {
33048
33049
  const classified = classifyKind(evidence);
33049
33050
  const contextCertainty = combineCertainty(classified.certainty, axis.certainty);
33050
33051
  const certainty = combineCertainty(contextCertainty, inlineDirection.certainty);
33052
+ const baselineRelevance = computeBaselineRelevance(classified.kind, parentAlignItems, parentPlaceItems);
33051
33053
  const out = {
33052
33054
  kind: classified.kind,
33053
33055
  certainty,
@@ -33063,6 +33065,7 @@ function createAlignmentContextForParent(parent, snapshot) {
33063
33065
  parentAlignItems,
33064
33066
  parentPlaceItems,
33065
33067
  hasPositionedOffset: positionedOffset.hasPositionedOffset,
33068
+ baselineRelevance,
33066
33069
  evidence
33067
33070
  };
33068
33071
  return out;
@@ -33283,6 +33286,63 @@ function combineCertainty(left, right) {
33283
33286
  if (left === "conditional" || right === "conditional") return "conditional";
33284
33287
  return "resolved";
33285
33288
  }
33289
+ var FLEX_GRID_GEOMETRIC_ALIGN_ITEMS = /* @__PURE__ */ new Set([
33290
+ "center",
33291
+ "flex-start",
33292
+ "flex-end",
33293
+ "start",
33294
+ "end",
33295
+ "stretch",
33296
+ "self-start",
33297
+ "self-end",
33298
+ "normal"
33299
+ ]);
33300
+ function computeBaselineRelevance(kind, parentAlignItems, parentPlaceItems) {
33301
+ if (kind === "flex-cross-axis" || kind === "grid-cross-axis") {
33302
+ const effective = resolveEffectiveAlignItems(parentAlignItems, parentPlaceItems);
33303
+ if (effective === null) return "relevant";
33304
+ return FLEX_GRID_GEOMETRIC_ALIGN_ITEMS.has(effective) ? "irrelevant" : "relevant";
33305
+ }
33306
+ return "relevant";
33307
+ }
33308
+ function resolveEffectiveAlignItems(alignItems, placeItems) {
33309
+ if (alignItems !== null) return alignItems;
33310
+ if (placeItems === null) return null;
33311
+ const firstToken2 = placeItems.split(WHITESPACE_RE4)[0];
33312
+ return firstToken2 ?? null;
33313
+ }
33314
+ var TABLE_CELL_GEOMETRIC_VERTICAL_ALIGN = /* @__PURE__ */ new Set([
33315
+ "middle",
33316
+ "top",
33317
+ "bottom"
33318
+ ]);
33319
+ function finalizeTableCellBaselineRelevance(contextByParentNode, cohortVerticalAlignConsensus) {
33320
+ for (const [parent, consensusValue] of cohortVerticalAlignConsensus) {
33321
+ const context = contextByParentNode.get(parent);
33322
+ if (!context) continue;
33323
+ if (context.kind !== "table-cell") continue;
33324
+ if (consensusValue === null) continue;
33325
+ if (!TABLE_CELL_GEOMETRIC_VERTICAL_ALIGN.has(consensusValue)) continue;
33326
+ contextByParentNode.set(parent, {
33327
+ kind: context.kind,
33328
+ certainty: context.certainty,
33329
+ parentSolidFile: context.parentSolidFile,
33330
+ parentElementId: context.parentElementId,
33331
+ parentElementKey: context.parentElementKey,
33332
+ parentTag: context.parentTag,
33333
+ axis: context.axis,
33334
+ axisCertainty: context.axisCertainty,
33335
+ inlineDirection: context.inlineDirection,
33336
+ inlineDirectionCertainty: context.inlineDirectionCertainty,
33337
+ parentDisplay: context.parentDisplay,
33338
+ parentAlignItems: context.parentAlignItems,
33339
+ parentPlaceItems: context.parentPlaceItems,
33340
+ hasPositionedOffset: context.hasPositionedOffset,
33341
+ baselineRelevance: "irrelevant",
33342
+ evidence: context.evidence
33343
+ });
33344
+ }
33345
+ }
33286
33346
 
33287
33347
  // src/cross-file/layout/consistency-domain.ts
33288
33348
  function summarizeSignalFacts(snapshots) {
@@ -33896,12 +33956,7 @@ function resolveInlineReplacedKindDivergence(subjectFingerprint, allFingerprints
33896
33956
  return alignmentStrengthCalibration.compositionMixedOutlierAmongReplacedStrength;
33897
33957
  }
33898
33958
  function hasSharedBaselineAlignment(context) {
33899
- if (context.kind === "inline-formatting" || context.kind === "table-cell") return true;
33900
- if (context.kind === "flex-cross-axis" || context.kind === "grid-cross-axis") {
33901
- const alignItems = context.parentAlignItems;
33902
- return alignItems === null || alignItems === "baseline";
33903
- }
33904
- return false;
33959
+ return context.baselineRelevance === "relevant";
33905
33960
  }
33906
33961
  function resolveMajorityClassification(allFingerprints) {
33907
33962
  const countByClassification = /* @__PURE__ */ new Map();
@@ -34055,6 +34110,7 @@ function estimateBlockOffsetWithDeclaredFromSources(axis, position, readNumeric)
34055
34110
  // src/cross-file/layout/cohort-index.ts
34056
34111
  function buildCohortIndex(input) {
34057
34112
  const statsByParentNode = /* @__PURE__ */ new Map();
34113
+ const verticalAlignConsensusByParent = /* @__PURE__ */ new Map();
34058
34114
  const profileBuffers = createCohortProfileBuffers();
34059
34115
  let conditionalSignals = 0;
34060
34116
  let totalSignals = 0;
@@ -34129,12 +34185,14 @@ function buildCohortIndex(input) {
34129
34185
  subjectsByElementKey,
34130
34186
  excludedElementKeys: cohortMetricsResult.excludedElementKeys
34131
34187
  });
34188
+ verticalAlignConsensusByParent.set(parent, resolveVerticalAlignConsensus(signalIndex.verticalAlign));
34132
34189
  conditionalSignals += counts.conditional;
34133
34190
  totalSignals += counts.total;
34134
34191
  if (!profile.unimodal) unimodalFalseCount++;
34135
34192
  }
34136
34193
  return {
34137
34194
  statsByParentNode,
34195
+ verticalAlignConsensusByParent,
34138
34196
  conditionalSignals,
34139
34197
  totalSignals,
34140
34198
  unimodalFalseCount,
@@ -34957,6 +35015,13 @@ function swap(values, left, right) {
34957
35015
  values[left] = rightValue;
34958
35016
  values[right] = leftValue;
34959
35017
  }
35018
+ function resolveVerticalAlignConsensus(aggregate) {
35019
+ if (aggregate.comparableCount === 0) return null;
35020
+ if (aggregate.countsByValue.size !== 1) return null;
35021
+ const firstEntry = aggregate.countsByValue.entries().next();
35022
+ if (firstEntry.done) return null;
35023
+ return firstEntry.value[0];
35024
+ }
34960
35025
 
34961
35026
  // src/cross-file/layout/measurement-node.ts
34962
35027
  var EMPTY_NODE_LIST = [];
@@ -36559,6 +36624,7 @@ function buildLayoutGraph(solids, css, logger = noopLogger) {
36559
36624
  snapshotByElementNode,
36560
36625
  snapshotHotSignalsByElementKey: factIndex.snapshotHotSignalsByElementKey
36561
36626
  });
36627
+ finalizeTableCellBaselineRelevance(contextByParentNode, cohortIndex.verticalAlignConsensusByParent);
36562
36628
  perf.conditionalSignals = cohortIndex.conditionalSignals;
36563
36629
  perf.totalSignals = cohortIndex.totalSignals;
36564
36630
  perf.cohortUnimodalFalse = cohortIndex.unimodalFalseCount;
@@ -36937,6 +37003,12 @@ function collectAlignmentCases(context) {
36937
37003
  if (!subjectStats) {
36938
37004
  throw new Error(`missing subject cohort stats for ${measurementNode.key}`);
36939
37005
  }
37006
+ const effectiveAlignmentContext = resolveEffectiveAlignmentContext(
37007
+ alignmentContext,
37008
+ child,
37009
+ measurementNode,
37010
+ context.layout.contextByParentNode
37011
+ );
36940
37012
  const subjectDeclaredOffsetDeviation = computeDeviation(
36941
37013
  subjectStats.declaredOffset,
36942
37014
  subjectStats.baselineProfile.medianDeclaredOffsetPx
@@ -36952,7 +37024,7 @@ function collectAlignmentCases(context) {
36952
37024
  out.push(
36953
37025
  buildAlignmentCase(
36954
37026
  parent,
36955
- alignmentContext,
37027
+ effectiveAlignmentContext,
36956
37028
  cohortStats.profile,
36957
37029
  subjectStats.signals,
36958
37030
  subjectStats.identifiability,
@@ -37101,6 +37173,31 @@ function collectCohortContentCompositions(cohortStats, children, measurementNode
37101
37173
  }
37102
37174
  return out;
37103
37175
  }
37176
+ function resolveEffectiveAlignmentContext(parentContext, child, measurementNode, contextByParentNode) {
37177
+ if (child === measurementNode) return parentContext;
37178
+ if (parentContext.baselineRelevance === "irrelevant") return parentContext;
37179
+ const childContext = contextByParentNode.get(child);
37180
+ if (!childContext) return parentContext;
37181
+ if (childContext.baselineRelevance !== "irrelevant") return parentContext;
37182
+ return {
37183
+ kind: parentContext.kind,
37184
+ certainty: parentContext.certainty,
37185
+ parentSolidFile: parentContext.parentSolidFile,
37186
+ parentElementId: parentContext.parentElementId,
37187
+ parentElementKey: parentContext.parentElementKey,
37188
+ parentTag: parentContext.parentTag,
37189
+ axis: parentContext.axis,
37190
+ axisCertainty: parentContext.axisCertainty,
37191
+ inlineDirection: parentContext.inlineDirection,
37192
+ inlineDirectionCertainty: parentContext.inlineDirectionCertainty,
37193
+ parentDisplay: parentContext.parentDisplay,
37194
+ parentAlignItems: parentContext.parentAlignItems,
37195
+ parentPlaceItems: parentContext.parentPlaceItems,
37196
+ hasPositionedOffset: parentContext.hasPositionedOffset,
37197
+ baselineRelevance: "irrelevant",
37198
+ evidence: parentContext.evidence
37199
+ };
37200
+ }
37104
37201
  function compareAlignmentCaseOrder(left, right) {
37105
37202
  if (left.subject.solidFile < right.subject.solidFile) return -1;
37106
37203
  if (left.subject.solidFile > right.subject.solidFile) return 1;
@@ -37133,10 +37230,11 @@ function buildConsistencyEvidence(input) {
37133
37230
  input.cohortProfile.lineHeightDispersionPx,
37134
37231
  input.cohortProfile.medianLineHeightPx
37135
37232
  );
37136
- const baselineStrength = resolveBaselineStrength(input, lineHeight);
37137
- const contextStrength = resolveContextStrength(input, lineHeight);
37138
- const replacedStrength = resolveReplacedControlStrength(input, lineHeight);
37139
- const compositionStrength = resolveContentCompositionStrength(input);
37233
+ const baselinesIrrelevant = input.context.baselineRelevance === "irrelevant";
37234
+ const baselineStrength = baselinesIrrelevant ? ZERO_STRENGTH : resolveBaselineStrength(input, lineHeight);
37235
+ const contextStrength = baselinesIrrelevant ? ZERO_STRENGTH : resolveContextStrength(input, lineHeight);
37236
+ const replacedStrength = baselinesIrrelevant ? ZERO_STRENGTH : resolveReplacedControlStrength(input, lineHeight);
37237
+ const compositionStrength = baselinesIrrelevant ? ZERO_STRENGTH : resolveContentCompositionStrength(input);
37140
37238
  const contextCertaintyPenalty = resolveContextCertaintyPenalty(input);
37141
37239
  const provenance = input.cohortProvenance;
37142
37240
  const atoms = buildEvidenceAtoms(
@@ -37432,6 +37530,7 @@ function toNegativeContribution(strength, maxPenalty, valueKind) {
37432
37530
  max: 0
37433
37531
  };
37434
37532
  }
37533
+ var ZERO_STRENGTH = { strength: 0, kind: "exact" };
37435
37534
 
37436
37535
  // src/cross-file/layout/consistency-policy.ts
37437
37536
  function applyConsistencyPolicy(input) {
@@ -37651,6 +37750,7 @@ function runLayoutDetector(context, detector) {
37651
37750
  const cases = detector.collect(context);
37652
37751
  const startedAt = performance.now();
37653
37752
  const out = [];
37753
+ const log = context.logger;
37654
37754
  for (let i = 0; i < cases.length; i++) {
37655
37755
  const current = cases[i];
37656
37756
  if (!current) continue;
@@ -37663,10 +37763,20 @@ function runLayoutDetector(context, detector) {
37663
37763
  result.evidence.posteriorLower,
37664
37764
  result.evidence.posteriorUpper
37665
37765
  );
37766
+ if (log.enabled) {
37767
+ log.debug(
37768
+ `[${detector.id}] accept case=${i} severity=${result.evidence.severity.toFixed(2)} confidence=${result.evidence.confidence.toFixed(2)} posterior=[${result.evidence.posteriorLower.toFixed(3)},${result.evidence.posteriorUpper.toFixed(3)}] evidenceMass=${result.evidence.evidenceMass.toFixed(3)} context=${result.evidence.contextKind} offset=${result.evidence.estimatedOffsetPx?.toFixed(2) ?? "null"} topFactors=[${result.evidence.topFactors.join(",")}] causes=[${result.evidence.causes.join("; ")}]`
37769
+ );
37770
+ }
37666
37771
  out.push({ caseData: current, evidence: result.evidence });
37667
37772
  continue;
37668
37773
  }
37669
37774
  recordPolicyMetrics(context, result.evidenceMass, result.posteriorLower, result.posteriorUpper);
37775
+ if (log.enabled) {
37776
+ log.debug(
37777
+ `[${detector.id}] reject case=${i} reason=${result.reason} detail=${result.detail ?? "none"} posterior=[${result.posteriorLower.toFixed(3)},${result.posteriorUpper.toFixed(3)}] evidenceMass=${result.evidenceMass.toFixed(3)}`
37778
+ );
37779
+ }
37670
37780
  if (result.reason === "low-evidence") {
37671
37781
  context.layout.perf.casesRejectedLowEvidence++;
37672
37782
  continue;
@@ -38440,33 +38550,73 @@ var cssLayoutSiblingAlignmentOutlier = defineCrossRule({
38440
38550
  category: "css-layout"
38441
38551
  },
38442
38552
  check(context, emit) {
38553
+ const log = context.logger;
38443
38554
  const detections = runLayoutDetector(context, siblingAlignmentDetector);
38444
38555
  const uniqueDetections = dedupeDetectionsBySubject(detections);
38556
+ if (log.enabled) {
38557
+ log.debug(
38558
+ `[sibling-alignment] raw=${detections.length} deduped=${uniqueDetections.length}`
38559
+ );
38560
+ }
38445
38561
  for (let i = 0; i < uniqueDetections.length; i++) {
38446
38562
  const detection = uniqueDetections[i];
38447
38563
  if (!detection) continue;
38448
- if (detection.evidence.confidence < MIN_CONFIDENCE_THRESHOLD) continue;
38564
+ const subjectTag = detection.caseData.subject.tag ?? "element";
38565
+ const parentTag = detection.caseData.cohort.parentTag ?? "container";
38566
+ const subjectFile = detection.caseData.subject.solidFile;
38567
+ const subjectId = detection.caseData.subject.elementId;
38568
+ const logPrefix = `[sibling-alignment] <${subjectTag}> in <${parentTag}> (${subjectFile}#${subjectId})`;
38569
+ if (detection.evidence.confidence < MIN_CONFIDENCE_THRESHOLD) {
38570
+ if (log.enabled) {
38571
+ log.debug(
38572
+ `${logPrefix} SKIP: confidence=${detection.evidence.confidence.toFixed(2)} < threshold=${MIN_CONFIDENCE_THRESHOLD}`
38573
+ );
38574
+ }
38575
+ continue;
38576
+ }
38449
38577
  const estimatedOffset = detection.evidence.estimatedOffsetPx;
38450
- if (estimatedOffset !== null && Math.abs(estimatedOffset) < MIN_OFFSET_PX_THRESHOLD && !hasNonOffsetPrimaryEvidence(detection.evidence.topFactors)) continue;
38578
+ if (estimatedOffset !== null && Math.abs(estimatedOffset) < MIN_OFFSET_PX_THRESHOLD && !hasNonOffsetPrimaryEvidence(detection.evidence.topFactors)) {
38579
+ if (log.enabled) {
38580
+ log.debug(
38581
+ `${logPrefix} SKIP: offset=${estimatedOffset.toFixed(2)}px < ${MIN_OFFSET_PX_THRESHOLD}px (no non-offset primary evidence, topFactors=[${detection.evidence.topFactors.join(",")}])`
38582
+ );
38583
+ }
38584
+ continue;
38585
+ }
38451
38586
  if (isInsideOutOfFlowAncestor(
38452
38587
  context.layout,
38453
38588
  detection.caseData.cohort.parentElementKey,
38454
38589
  detection.caseData.subject.solidFile
38455
- )) continue;
38590
+ )) {
38591
+ if (log.enabled) {
38592
+ log.debug(`${logPrefix} SKIP: out-of-flow ancestor`);
38593
+ }
38594
+ continue;
38595
+ }
38456
38596
  const subjectRef = readNodeRefById(
38457
38597
  context.layout,
38458
38598
  detection.caseData.subject.solidFile,
38459
38599
  detection.caseData.subject.elementId
38460
38600
  );
38461
- if (!subjectRef) continue;
38462
- const subject = detection.caseData.subject.tag ?? "element";
38463
- const parent = detection.caseData.cohort.parentTag ?? "container";
38601
+ if (!subjectRef) {
38602
+ if (log.enabled) {
38603
+ log.debug(`${logPrefix} SKIP: no node ref`);
38604
+ }
38605
+ continue;
38606
+ }
38607
+ const subject = subjectTag;
38608
+ const parent = parentTag;
38464
38609
  const severity = formatFixed(detection.evidence.severity);
38465
38610
  const confidence = formatFixed(detection.evidence.confidence);
38466
38611
  const offset = detection.evidence.estimatedOffsetPx;
38467
38612
  const hasOffset = offset !== null && Math.abs(offset) > 0.25;
38468
38613
  const offsetClause = hasOffset ? `, estimated offset ${formatFixed(offset)}px` : "";
38469
38614
  const causes = detection.evidence.causes.length === 0 ? "alignment signals indicate an outlier" : detection.evidence.causes.join("; ");
38615
+ if (log.enabled) {
38616
+ log.debug(
38617
+ `${logPrefix} EMIT: severity=${severity} confidence=${confidence} offset=${offset?.toFixed(2) ?? "null"} posterior=[${detection.evidence.posteriorLower.toFixed(3)},${detection.evidence.posteriorUpper.toFixed(3)}] evidenceMass=${detection.evidence.evidenceMass.toFixed(3)} topFactors=[${detection.evidence.topFactors.join(",")}] causes=[${causes}]`
38618
+ );
38619
+ }
38470
38620
  emit(
38471
38621
  createDiagnostic(
38472
38622
  subjectRef.solid.file,
@@ -39875,7 +40025,8 @@ var CrossFilePlugin = {
39875
40025
  const context = {
39876
40026
  solids: solidGraphs,
39877
40027
  css: cssGraph,
39878
- layout: buildLayoutGraph(solidGraphs, cssGraph)
40028
+ layout: buildLayoutGraph(solidGraphs, cssGraph),
40029
+ logger: noopLogger
39879
40030
  };
39880
40031
  runCrossFileRules(context, emit);
39881
40032
  }
@@ -39910,4 +40061,4 @@ export {
39910
40061
  rules3,
39911
40062
  runCrossFileRules
39912
40063
  };
39913
- //# sourceMappingURL=chunk-LGHIMW4P.js.map
40064
+ //# sourceMappingURL=chunk-PX2XCAZW.js.map