@drskillissue/ganko 0.1.18 → 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.
@@ -24726,7 +24726,8 @@ var cssRequireReducedMotionOverride = defineCSSRule({
24726
24726
  for (let j = 0; j < resolved.length; j++) {
24727
24727
  const sel = resolved[j];
24728
24728
  if (!sel) continue;
24729
- reduced.add(`${normalizeSelector(sel)}|${group}`);
24729
+ const key = `${normalizeSelector(sel)}|${group}`;
24730
+ reduced.add(key);
24730
24731
  }
24731
24732
  }
24732
24733
  for (let i = 0; i < motionDecls.length; i++) {
@@ -24745,7 +24746,8 @@ var cssRequireReducedMotionOverride = defineCSSRule({
24745
24746
  for (let j = 0; j < resolved.length; j++) {
24746
24747
  const sel = resolved[j];
24747
24748
  if (!sel) continue;
24748
- if (reduced.has(`${normalizeSelector(sel)}|${group}`)) {
24749
+ const key = `${normalizeSelector(sel)}|${group}`;
24750
+ if (reduced.has(key)) {
24749
24751
  covered = true;
24750
24752
  break;
24751
24753
  }
@@ -32930,6 +32932,16 @@ function readKnownNormalizedWithGuard(snapshot, name) {
32930
32932
  if (!value2) return null;
32931
32933
  return value2.normalized;
32932
32934
  }
32935
+ function isLayoutHidden(node, snapshotByElementNode) {
32936
+ if (node.attributes.has("hidden")) return true;
32937
+ if (node.classTokenSet.has("hidden")) return true;
32938
+ const snapshot = snapshotByElementNode.get(node);
32939
+ if (snapshot) {
32940
+ const display = readKnownNormalized(snapshot, "display");
32941
+ if (display === "none") return true;
32942
+ }
32943
+ return false;
32944
+ }
32933
32945
  function hasEffectivePosition(snapshot) {
32934
32946
  const position = readKnownNormalized(snapshot, "position");
32935
32947
  if (position === null) return false;
@@ -32998,6 +33010,7 @@ function readStatefulBaseValueIndex(graph) {
32998
33010
  }
32999
33011
 
33000
33012
  // src/cross-file/layout/context-classification.ts
33013
+ var WHITESPACE_RE4 = /\s+/;
33001
33014
  var TABLE_SEMANTIC_TAGS = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot", "tr", "td", "th"]);
33002
33015
  var TABLE_DISPLAY_VALUES = /* @__PURE__ */ new Set([
33003
33016
  "table",
@@ -33036,6 +33049,7 @@ function createAlignmentContextForParent(parent, snapshot) {
33036
33049
  const classified = classifyKind(evidence);
33037
33050
  const contextCertainty = combineCertainty(classified.certainty, axis.certainty);
33038
33051
  const certainty = combineCertainty(contextCertainty, inlineDirection.certainty);
33052
+ const baselineRelevance = computeBaselineRelevance(classified.kind, parentAlignItems, parentPlaceItems);
33039
33053
  const out = {
33040
33054
  kind: classified.kind,
33041
33055
  certainty,
@@ -33051,6 +33065,7 @@ function createAlignmentContextForParent(parent, snapshot) {
33051
33065
  parentAlignItems,
33052
33066
  parentPlaceItems,
33053
33067
  hasPositionedOffset: positionedOffset.hasPositionedOffset,
33068
+ baselineRelevance,
33054
33069
  evidence
33055
33070
  };
33056
33071
  return out;
@@ -33271,6 +33286,63 @@ function combineCertainty(left, right) {
33271
33286
  if (left === "conditional" || right === "conditional") return "conditional";
33272
33287
  return "resolved";
33273
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
+ }
33274
33346
 
33275
33347
  // src/cross-file/layout/consistency-domain.ts
33276
33348
  function summarizeSignalFacts(snapshots) {
@@ -33884,12 +33956,7 @@ function resolveInlineReplacedKindDivergence(subjectFingerprint, allFingerprints
33884
33956
  return alignmentStrengthCalibration.compositionMixedOutlierAmongReplacedStrength;
33885
33957
  }
33886
33958
  function hasSharedBaselineAlignment(context) {
33887
- if (context.kind === "inline-formatting" || context.kind === "table-cell") return true;
33888
- if (context.kind === "flex-cross-axis" || context.kind === "grid-cross-axis") {
33889
- const alignItems = context.parentAlignItems;
33890
- return alignItems === null || alignItems === "baseline";
33891
- }
33892
- return false;
33959
+ return context.baselineRelevance === "relevant";
33893
33960
  }
33894
33961
  function resolveMajorityClassification(allFingerprints) {
33895
33962
  const countByClassification = /* @__PURE__ */ new Map();
@@ -34043,6 +34110,7 @@ function estimateBlockOffsetWithDeclaredFromSources(axis, position, readNumeric)
34043
34110
  // src/cross-file/layout/cohort-index.ts
34044
34111
  function buildCohortIndex(input) {
34045
34112
  const statsByParentNode = /* @__PURE__ */ new Map();
34113
+ const verticalAlignConsensusByParent = /* @__PURE__ */ new Map();
34046
34114
  const profileBuffers = createCohortProfileBuffers();
34047
34115
  let conditionalSignals = 0;
34048
34116
  let totalSignals = 0;
@@ -34117,12 +34185,14 @@ function buildCohortIndex(input) {
34117
34185
  subjectsByElementKey,
34118
34186
  excludedElementKeys: cohortMetricsResult.excludedElementKeys
34119
34187
  });
34188
+ verticalAlignConsensusByParent.set(parent, resolveVerticalAlignConsensus(signalIndex.verticalAlign));
34120
34189
  conditionalSignals += counts.conditional;
34121
34190
  totalSignals += counts.total;
34122
34191
  if (!profile.unimodal) unimodalFalseCount++;
34123
34192
  }
34124
34193
  return {
34125
34194
  statsByParentNode,
34195
+ verticalAlignConsensusByParent,
34126
34196
  conditionalSignals,
34127
34197
  totalSignals,
34128
34198
  unimodalFalseCount,
@@ -34142,6 +34212,10 @@ function collectCohortMetrics(input) {
34142
34212
  const node = input.children[i];
34143
34213
  if (!node) continue;
34144
34214
  const childSnapshot = input.snapshotByElementNode.get(node);
34215
+ if (isLayoutHidden(node, input.snapshotByElementNode)) {
34216
+ excluded.add(node.key);
34217
+ continue;
34218
+ }
34145
34219
  if (childSnapshot && isUnconditionallyOutOfFlow(childSnapshot)) {
34146
34220
  excluded.add(node.key);
34147
34221
  continue;
@@ -34941,6 +35015,13 @@ function swap(values, left, right) {
34941
35015
  values[left] = rightValue;
34942
35016
  values[right] = leftValue;
34943
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
+ }
34944
35025
 
34945
35026
  // src/cross-file/layout/measurement-node.ts
34946
35027
  var EMPTY_NODE_LIST = [];
@@ -35028,6 +35109,7 @@ function resolveMeasurementCandidates(root, childrenByParentNode, snapshotByElem
35028
35109
  for (let i = 0; i < children.length; i++) {
35029
35110
  const child = children[i];
35030
35111
  if (!child) continue;
35112
+ if (isLayoutHidden(child, snapshotByElementNode)) continue;
35031
35113
  if (firstControlOrReplacedDescendant === null && (child.isControl || child.isReplaced)) {
35032
35114
  firstControlOrReplacedDescendant = child;
35033
35115
  }
@@ -36542,6 +36624,7 @@ function buildLayoutGraph(solids, css, logger = noopLogger) {
36542
36624
  snapshotByElementNode,
36543
36625
  snapshotHotSignalsByElementKey: factIndex.snapshotHotSignalsByElementKey
36544
36626
  });
36627
+ finalizeTableCellBaselineRelevance(contextByParentNode, cohortIndex.verticalAlignConsensusByParent);
36545
36628
  perf.conditionalSignals = cohortIndex.conditionalSignals;
36546
36629
  perf.totalSignals = cohortIndex.totalSignals;
36547
36630
  perf.cohortUnimodalFalse = cohortIndex.unimodalFalseCount;
@@ -36920,6 +37003,12 @@ function collectAlignmentCases(context) {
36920
37003
  if (!subjectStats) {
36921
37004
  throw new Error(`missing subject cohort stats for ${measurementNode.key}`);
36922
37005
  }
37006
+ const effectiveAlignmentContext = resolveEffectiveAlignmentContext(
37007
+ alignmentContext,
37008
+ child,
37009
+ measurementNode,
37010
+ context.layout.contextByParentNode
37011
+ );
36923
37012
  const subjectDeclaredOffsetDeviation = computeDeviation(
36924
37013
  subjectStats.declaredOffset,
36925
37014
  subjectStats.baselineProfile.medianDeclaredOffsetPx
@@ -36935,7 +37024,7 @@ function collectAlignmentCases(context) {
36935
37024
  out.push(
36936
37025
  buildAlignmentCase(
36937
37026
  parent,
36938
- alignmentContext,
37027
+ effectiveAlignmentContext,
36939
37028
  cohortStats.profile,
36940
37029
  subjectStats.signals,
36941
37030
  subjectStats.identifiability,
@@ -37084,6 +37173,31 @@ function collectCohortContentCompositions(cohortStats, children, measurementNode
37084
37173
  }
37085
37174
  return out;
37086
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
+ }
37087
37201
  function compareAlignmentCaseOrder(left, right) {
37088
37202
  if (left.subject.solidFile < right.subject.solidFile) return -1;
37089
37203
  if (left.subject.solidFile > right.subject.solidFile) return 1;
@@ -37116,10 +37230,11 @@ function buildConsistencyEvidence(input) {
37116
37230
  input.cohortProfile.lineHeightDispersionPx,
37117
37231
  input.cohortProfile.medianLineHeightPx
37118
37232
  );
37119
- const baselineStrength = resolveBaselineStrength(input, lineHeight);
37120
- const contextStrength = resolveContextStrength(input, lineHeight);
37121
- const replacedStrength = resolveReplacedControlStrength(input, lineHeight);
37122
- 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);
37123
37238
  const contextCertaintyPenalty = resolveContextCertaintyPenalty(input);
37124
37239
  const provenance = input.cohortProvenance;
37125
37240
  const atoms = buildEvidenceAtoms(
@@ -37415,6 +37530,7 @@ function toNegativeContribution(strength, maxPenalty, valueKind) {
37415
37530
  max: 0
37416
37531
  };
37417
37532
  }
37533
+ var ZERO_STRENGTH = { strength: 0, kind: "exact" };
37418
37534
 
37419
37535
  // src/cross-file/layout/consistency-policy.ts
37420
37536
  function applyConsistencyPolicy(input) {
@@ -37634,6 +37750,7 @@ function runLayoutDetector(context, detector) {
37634
37750
  const cases = detector.collect(context);
37635
37751
  const startedAt = performance.now();
37636
37752
  const out = [];
37753
+ const log = context.logger;
37637
37754
  for (let i = 0; i < cases.length; i++) {
37638
37755
  const current = cases[i];
37639
37756
  if (!current) continue;
@@ -37646,10 +37763,20 @@ function runLayoutDetector(context, detector) {
37646
37763
  result.evidence.posteriorLower,
37647
37764
  result.evidence.posteriorUpper
37648
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
+ }
37649
37771
  out.push({ caseData: current, evidence: result.evidence });
37650
37772
  continue;
37651
37773
  }
37652
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
+ }
37653
37780
  if (result.reason === "low-evidence") {
37654
37781
  context.layout.perf.casesRejectedLowEvidence++;
37655
37782
  continue;
@@ -38423,33 +38550,73 @@ var cssLayoutSiblingAlignmentOutlier = defineCrossRule({
38423
38550
  category: "css-layout"
38424
38551
  },
38425
38552
  check(context, emit) {
38553
+ const log = context.logger;
38426
38554
  const detections = runLayoutDetector(context, siblingAlignmentDetector);
38427
38555
  const uniqueDetections = dedupeDetectionsBySubject(detections);
38556
+ if (log.enabled) {
38557
+ log.debug(
38558
+ `[sibling-alignment] raw=${detections.length} deduped=${uniqueDetections.length}`
38559
+ );
38560
+ }
38428
38561
  for (let i = 0; i < uniqueDetections.length; i++) {
38429
38562
  const detection = uniqueDetections[i];
38430
38563
  if (!detection) continue;
38431
- 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
+ }
38432
38577
  const estimatedOffset = detection.evidence.estimatedOffsetPx;
38433
- 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
+ }
38434
38586
  if (isInsideOutOfFlowAncestor(
38435
38587
  context.layout,
38436
38588
  detection.caseData.cohort.parentElementKey,
38437
38589
  detection.caseData.subject.solidFile
38438
- )) continue;
38590
+ )) {
38591
+ if (log.enabled) {
38592
+ log.debug(`${logPrefix} SKIP: out-of-flow ancestor`);
38593
+ }
38594
+ continue;
38595
+ }
38439
38596
  const subjectRef = readNodeRefById(
38440
38597
  context.layout,
38441
38598
  detection.caseData.subject.solidFile,
38442
38599
  detection.caseData.subject.elementId
38443
38600
  );
38444
- if (!subjectRef) continue;
38445
- const subject = detection.caseData.subject.tag ?? "element";
38446
- 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;
38447
38609
  const severity = formatFixed(detection.evidence.severity);
38448
38610
  const confidence = formatFixed(detection.evidence.confidence);
38449
38611
  const offset = detection.evidence.estimatedOffsetPx;
38450
38612
  const hasOffset = offset !== null && Math.abs(offset) > 0.25;
38451
38613
  const offsetClause = hasOffset ? `, estimated offset ${formatFixed(offset)}px` : "";
38452
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
+ }
38453
38620
  emit(
38454
38621
  createDiagnostic(
38455
38622
  subjectRef.solid.file,
@@ -39858,7 +40025,8 @@ var CrossFilePlugin = {
39858
40025
  const context = {
39859
40026
  solids: solidGraphs,
39860
40027
  css: cssGraph,
39861
- layout: buildLayoutGraph(solidGraphs, cssGraph)
40028
+ layout: buildLayoutGraph(solidGraphs, cssGraph),
40029
+ logger: noopLogger
39862
40030
  };
39863
40031
  runCrossFileRules(context, emit);
39864
40032
  }
@@ -39893,4 +40061,4 @@ export {
39893
40061
  rules3,
39894
40062
  runCrossFileRules
39895
40063
  };
39896
- //# sourceMappingURL=chunk-OYGFWDEL.js.map
40064
+ //# sourceMappingURL=chunk-PX2XCAZW.js.map