@drskillissue/ganko 0.2.61 → 0.2.71

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.
@@ -142,9 +142,29 @@ function canonicalPath(path) {
142
142
  return canonical;
143
143
  }
144
144
  var LOG_LEVELS = ["trace", "debug", "info", "warning", "error", "critical", "off"];
145
+ var Level = {
146
+ Trace: 0,
147
+ Debug: 1,
148
+ Info: 2,
149
+ Warning: 3,
150
+ Error: 4,
151
+ Critical: 5,
152
+ Off: 6
153
+ };
154
+ var LOG_LEVEL_ORDER = {
155
+ trace: Level.Trace,
156
+ debug: Level.Debug,
157
+ info: Level.Info,
158
+ warning: Level.Warning,
159
+ error: Level.Error,
160
+ critical: Level.Critical,
161
+ off: Level.Off
162
+ };
145
163
  var noopLogger = {
146
- enabled: false,
147
164
  level: "off",
165
+ isLevelEnabled() {
166
+ return false;
167
+ },
148
168
  trace() {
149
169
  },
150
170
  debug() {
@@ -2913,6 +2933,35 @@ var TypeResolver = class {
2913
2933
  return false;
2914
2934
  }
2915
2935
  }
2936
+ /**
2937
+ * Strict array check: only matches Array<T>, T[], ReadonlyArray<T>, and tuples.
2938
+ * Does NOT match typed arrays (Uint8Array, Buffer, etc.) or other types with
2939
+ * a numeric index signature.
2940
+ */
2941
+ isStrictArrayType(node) {
2942
+ try {
2943
+ const tsType = this.checker.getTypeAtLocation(node);
2944
+ return this.checkIsStrictArrayType(tsType);
2945
+ } catch {
2946
+ return false;
2947
+ }
2948
+ }
2949
+ checkIsStrictArrayType(tsType) {
2950
+ if (tsType.flags & 524288) {
2951
+ const objFlags = getObjectFlags(tsType);
2952
+ if (objFlags & 8) return true;
2953
+ if (objFlags & 4) {
2954
+ const name = tsType.getSymbol()?.getName();
2955
+ if (name === "Array" || name === "ReadonlyArray") return true;
2956
+ }
2957
+ }
2958
+ if (tsType.isUnion()) {
2959
+ for (const t of tsType.types) {
2960
+ if (this.checkIsStrictArrayType(t)) return true;
2961
+ }
2962
+ }
2963
+ return false;
2964
+ }
2916
2965
  checkIsArrayType(tsType) {
2917
2966
  if (tsType.flags & 524288) {
2918
2967
  const objFlags = getObjectFlags(tsType);
@@ -2964,7 +3013,7 @@ var TypeResolver = class {
2964
3013
  if (exprTsType.flags & import_typescript2.default.TypeFlags.Any) return false;
2965
3014
  if (targetTsType.flags & import_typescript2.default.TypeFlags.Any) return false;
2966
3015
  const result = this.checker.isTypeAssignableTo(exprTsType, targetTsType);
2967
- if (this.logger.enabled) {
3016
+ if (this.logger.isLevelEnabled(Level.Debug)) {
2968
3017
  const exprStr = this.checker.typeToString(exprTsType);
2969
3018
  const targetStr = this.checker.typeToString(targetTsType);
2970
3019
  this.logger.debug(`isUnnecessaryCast: expr="${exprStr.slice(0, 120)}" target="${targetStr.slice(0, 120)}" assignable=${result} exprFlags=${exprTsType.flags} targetFlags=${targetTsType.flags}`);
@@ -3481,6 +3530,7 @@ function getStaticStringFromJSXValue(node) {
3481
3530
  const expression = node.expression;
3482
3531
  if (!expression) return null;
3483
3532
  if (import_typescript4.default.isStringLiteral(expression)) return expression.text;
3533
+ if (import_typescript4.default.isNumericLiteral(expression)) return expression.text;
3484
3534
  if (import_typescript4.default.isNoSubstitutionTemplateLiteral(expression)) return expression.text;
3485
3535
  if (import_typescript4.default.isTemplateExpression(expression) && expression.templateSpans.length === 0) {
3486
3536
  return expression.head.text;
@@ -9928,6 +9978,9 @@ function typeIncludesString(graph, node) {
9928
9978
  function typeIsArray(graph, node) {
9929
9979
  return graph.typeResolver.isArrayType(node);
9930
9980
  }
9981
+ function typeIsStrictArray(graph, node) {
9982
+ return graph.typeResolver.isStrictArrayType(node);
9983
+ }
9931
9984
  function getArrayElementKind(graph, node) {
9932
9985
  return graph.typeResolver.getArrayElementKind(node);
9933
9986
  }
@@ -19723,6 +19776,7 @@ var preferSetLookupInLoop = defineSolidRule({
19723
19776
  options: options77,
19724
19777
  check(graph, emit) {
19725
19778
  const reported = /* @__PURE__ */ new Set();
19779
+ const graphHasTypes = hasTypeInfo(graph);
19726
19780
  for (const method of LINEAR_SEARCH_METHODS) {
19727
19781
  const calls = getCallsByMethodName(graph, method);
19728
19782
  for (let i = 0, len = calls.length; i < len; i++) {
@@ -19740,6 +19794,7 @@ var preferSetLookupInLoop = defineSolidRule({
19740
19794
  const loop = getEnclosingLoop(call.node);
19741
19795
  if (!loop) continue;
19742
19796
  if (!isDeclaredOutsideLoop2(loop, variable)) continue;
19797
+ if (graphHasTypes && !typeIsStrictArray(graph, callee.expression)) continue;
19743
19798
  if (isStringLikeReceiver(graph, callee.expression, variable)) continue;
19744
19799
  const key = `${loop.pos}:var:${variable.id}`;
19745
19800
  if (reported.has(key)) continue;
@@ -31012,6 +31067,9 @@ function readBaselineOffsetFacts(graph, node) {
31012
31067
  function readElementRef(graph, node) {
31013
31068
  return readElementRefById(graph, node.solidFile, node.elementId);
31014
31069
  }
31070
+ function readHostElementRef(graph, node) {
31071
+ return graph.hostElementRefsByNode.get(node) ?? null;
31072
+ }
31015
31073
  function readElementRefById(graph, solidFile, elementId) {
31016
31074
  const refs = graph.elementRefsBySolidFileAndId.get(solidFile);
31017
31075
  if (!refs) return null;
@@ -32077,7 +32135,7 @@ function publishLayoutPerfStatsForTest(stats) {
32077
32135
  }
32078
32136
  function maybeLogLayoutPerf(stats, log) {
32079
32137
  if (process.env["SOLID_LINT_LAYOUT_PROFILE"] !== "1") return;
32080
- if (!log || !log.enabled) return;
32138
+ if (!log || !log.isLevelEnabled(Level.Debug)) return;
32081
32139
  const view = snapshotLayoutPerfStats(stats);
32082
32140
  log.debug(
32083
32141
  `[layout] elements=${view.elementsScanned} candidates=${view.selectorCandidatesChecked} compiledSelectors=${view.compiledSelectorCount} unsupportedSelectors=${view.selectorsRejectedUnsupported} conditionalSelectors=${view.selectorsGuardedConditional} ancestryChecks=${view.ancestryChecks} edges=${view.matchEdgesCreated} collected=${view.casesCollected} cases=${view.casesScored} rejectLowEvidence=${view.casesRejectedLowEvidence} rejectThreshold=${view.casesRejectedThreshold} rejectUndecidable=${view.casesRejectedUndecidable} rejectIdentifiability=${view.casesRejectedIdentifiability} undecidableInterval=${view.undecidableInterval} conditionalSignalRatio=${Math.round(view.conditionalSignalRatio * 1e3) / 1e3} conditionalSignals=${view.conditionalSignals} totalSignals=${view.totalSignals} cohortUnimodalFalse=${view.cohortUnimodalFalse} factorCoverageMean=${Math.round(view.factorCoverageMean * 1e3) / 1e3} posteriorWidthP95=${Math.round(view.posteriorWidthP95 * 1e3) / 1e3} uncertaintyEscalations=${view.uncertaintyEscalations} snapshots=${view.signalSnapshotsBuilt} snapshotHits=${view.signalSnapshotCacheHits} measurementIndexHits=${view.measurementIndexHits} contexts=${view.contextsClassified} diagnostics=${view.diagnosticsEmitted} selectorIndexMs=${Math.round(view.selectorIndexMs * 100) / 100} selectorMatchMs=${Math.round(view.selectorMatchMs * 100) / 100} cascadeBuildMs=${Math.round(view.cascadeBuildMs * 100) / 100} caseBuildMs=${Math.round(view.caseBuildMs * 100) / 100} scoringMs=${Math.round(view.scoringMs * 100) / 100} elapsedMs=${Math.round(view.elapsedMs * 100) / 100}`
@@ -32142,17 +32200,17 @@ function createLayoutComponentHostResolver(solids, moduleResolver, logger = noop
32142
32200
  if (cached !== void 0) return cached;
32143
32201
  const binding = resolveTagBinding(normalizedFile, tag);
32144
32202
  if (binding === null) {
32145
- if (logger.enabled) logger.trace(`[component-host] resolveHost(${tag}): binding=null`);
32203
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] resolveHost(${tag}): binding=null`);
32146
32204
  hostByTagCache.set(cacheKey, null);
32147
32205
  return null;
32148
32206
  }
32149
32207
  if (binding.kind === "component") {
32150
- if (logger.enabled) logger.trace(`[component-host] resolveHost(${tag}): component, tagName=${binding.host.tagName}, attrs=[${[...binding.host.staticAttributes.keys()]}]`);
32208
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] resolveHost(${tag}): component, tagName=${binding.host.descriptor.tagName}, attrs=[${[...binding.host.descriptor.staticAttributes.keys()]}]`);
32151
32209
  hostByTagCache.set(cacheKey, binding.host);
32152
32210
  return binding.host;
32153
32211
  }
32154
32212
  const host = binding.base ? binding.base.host : null;
32155
- if (logger.enabled) logger.trace(`[component-host] resolveHost(${tag}): namespace, base=${host?.tagName ?? "null"}`);
32213
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] resolveHost(${tag}): namespace, base=${host?.descriptor.tagName ?? "null"}`);
32156
32214
  hostByTagCache.set(cacheKey, host);
32157
32215
  return host;
32158
32216
  },
@@ -32165,26 +32223,26 @@ function createLayoutComponentHostResolver(solids, moduleResolver, logger = noop
32165
32223
  }
32166
32224
  };
32167
32225
  function resolveComponentHostEntry(entry) {
32168
- if (entry.resolution === "resolved") return entry.descriptor;
32169
- if (logger.enabled) logger.trace(`[component-host] resolveComponentHostEntry: deferred innerTag=${entry.innerTag}, file=${entry.filePath}, attrs=[${[...entry.staticAttributes.keys()]}]`);
32226
+ if (entry.resolution === "resolved") {
32227
+ return { descriptor: entry.descriptor, hostElementRef: entry.hostElementRef };
32228
+ }
32229
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] resolveComponentHostEntry: deferred innerTag=${entry.innerTag}, file=${entry.filePath}, attrs=[${[...entry.staticAttributes.keys()]}]`);
32170
32230
  const innerBinding = resolveLocalIdentifierBinding(entry.filePath, entry.innerTag);
32171
- if (logger.enabled) logger.trace(`[component-host] innerBinding=${innerBinding === null ? "null" : innerBinding.kind}`);
32231
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] innerBinding=${innerBinding === null ? "null" : innerBinding.kind}`);
32172
32232
  const innerHost = extractHostFromBinding(innerBinding);
32173
- if (logger.enabled) logger.trace(`[component-host] innerHost=${innerHost === null ? "null" : `tagName=${innerHost.tagName}, attrs=[${[...innerHost.staticAttributes.keys()]}]`}`);
32174
- let tagName = innerHost !== null ? innerHost.tagName : null;
32233
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] innerHost=${innerHost === null ? "null" : `tagName=${innerHost.descriptor.tagName}, attrs=[${[...innerHost.descriptor.staticAttributes.keys()]}]`}`);
32234
+ let tagName = innerHost !== null ? innerHost.descriptor.tagName : null;
32175
32235
  if (tagName === null) {
32176
32236
  tagName = resolveTagNameFromPolymorphicProp(entry.staticAttributes);
32177
- if (logger.enabled) logger.trace(`[component-host] polymorphic fallback: tagName=${tagName}`);
32237
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] polymorphic fallback: tagName=${tagName}`);
32178
32238
  }
32179
- const staticAttributes = innerHost !== null ? mergeStaticAttributes(entry.staticAttributes, innerHost.staticAttributes) : entry.staticAttributes;
32180
- const staticClassTokens = innerHost !== null ? mergeStaticClassTokens(entry.staticClassTokens, innerHost.staticClassTokens) : entry.staticClassTokens;
32181
- const forwardsChildren = entry.forwardsChildren || innerHost !== null && innerHost.forwardsChildren;
32182
- if (logger.enabled) logger.trace(`[component-host] resolved: tagName=${tagName}, attrs=[${[...staticAttributes.keys()]}], classes=[${staticClassTokens}]`);
32239
+ const staticAttributes = innerHost !== null ? mergeStaticAttributes(entry.staticAttributes, innerHost.descriptor.staticAttributes) : entry.staticAttributes;
32240
+ const staticClassTokens = innerHost !== null ? mergeStaticClassTokens(entry.staticClassTokens, innerHost.descriptor.staticClassTokens) : entry.staticClassTokens;
32241
+ const forwardsChildren = entry.forwardsChildren || innerHost !== null && innerHost.descriptor.forwardsChildren;
32242
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] resolved: tagName=${tagName}, attrs=[${[...staticAttributes.keys()]}], classes=[${staticClassTokens}]`);
32183
32243
  return {
32184
- tagName,
32185
- staticAttributes,
32186
- staticClassTokens,
32187
- forwardsChildren
32244
+ descriptor: { tagName, staticAttributes, staticClassTokens, forwardsChildren },
32245
+ hostElementRef: innerHost?.hostElementRef ?? null
32188
32246
  };
32189
32247
  }
32190
32248
  function extractHostFromBinding(binding) {
@@ -32225,10 +32283,7 @@ function createLayoutComponentHostResolver(solids, moduleResolver, logger = noop
32225
32283
  if (hostEntry) {
32226
32284
  const resolved = resolveComponentHostEntry(hostEntry);
32227
32285
  if (resolved !== null) {
32228
- const binding = {
32229
- kind: "component",
32230
- host: resolved
32231
- };
32286
+ const binding = { kind: "component", host: resolved };
32232
32287
  localBindingCache.set(key, binding);
32233
32288
  resolvingLocal.delete(key);
32234
32289
  return binding;
@@ -32289,7 +32344,7 @@ function createLayoutComponentHostResolver(solids, moduleResolver, logger = noop
32289
32344
  const baseExpression = toExpressionArgument(firstArg);
32290
32345
  if (baseExpression === null) return null;
32291
32346
  const baseBinding = resolveBindingFromExpression(filePath, baseExpression);
32292
- if (logger.enabled) logger.trace(`[component-host] Object.assign base: ${baseBinding === null ? "null" : baseBinding.kind}${baseBinding?.kind === "component" ? `, tagName=${baseBinding.host.tagName}` : ""}`);
32347
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] Object.assign base: ${baseBinding === null ? "null" : baseBinding.kind}${baseBinding?.kind === "component" ? `, tagName=${baseBinding.host.descriptor.tagName}` : ""}`);
32293
32348
  let baseComponent = null;
32294
32349
  const members = /* @__PURE__ */ new Map();
32295
32350
  if (baseBinding && baseBinding.kind === "component") {
@@ -32315,7 +32370,7 @@ function createLayoutComponentHostResolver(solids, moduleResolver, logger = noop
32315
32370
  if (!import_typescript125.default.isObjectLiteralExpression(argument)) continue;
32316
32371
  appendObjectExpressionMembers(filePath, argument, members);
32317
32372
  }
32318
- if (logger.enabled) logger.trace(`[component-host] Object.assign result: base=${baseComponent === null ? "null" : `tagName=${baseComponent.host.tagName}`}, members=[${[...members.keys()]}]`);
32373
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] Object.assign result: base=${baseComponent === null ? "null" : `tagName=${baseComponent.host.descriptor.tagName}`}, members=[${[...members.keys()]}]`);
32319
32374
  if (baseComponent === null && members.size === 0) return null;
32320
32375
  return {
32321
32376
  kind: "namespace",
@@ -32357,7 +32412,7 @@ function createLayoutComponentHostResolver(solids, moduleResolver, logger = noop
32357
32412
  }
32358
32413
  function resolveBindingFromImport(filePath, importBinding) {
32359
32414
  const resolvedModule = moduleResolver.resolveSolid(filePath, importBinding.source) ?? resolveAndIndexExternalModule(filePath, importBinding.source);
32360
- if (logger.enabled) logger.trace(`[component-host] resolveBindingFromImport: source=${importBinding.source}, kind=${importBinding.kind}, resolvedModule=${resolvedModule}`);
32415
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] resolveBindingFromImport: source=${importBinding.source}, kind=${importBinding.kind}, resolvedModule=${resolvedModule}`);
32361
32416
  if (resolvedModule === null) return null;
32362
32417
  const normalized = (0, import_node_path3.resolve)(resolvedModule);
32363
32418
  if (importBinding.kind === "namespace") {
@@ -32366,7 +32421,7 @@ function createLayoutComponentHostResolver(solids, moduleResolver, logger = noop
32366
32421
  const exportName = importBinding.kind === "default" ? "default" : importBinding.importedName;
32367
32422
  if (exportName === null) return null;
32368
32423
  const result = resolveExportBinding(normalized, exportName);
32369
- if (logger.enabled) logger.trace(`[component-host] export ${exportName}: ${result === null ? "null" : result.kind}`);
32424
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[component-host] export ${exportName}: ${result === null ? "null" : result.kind}`);
32370
32425
  return result;
32371
32426
  }
32372
32427
  function resolveAndIndexExternalModule(importerFile, importSource) {
@@ -32560,6 +32615,7 @@ function collectComponentHosts(graph) {
32560
32615
  }
32561
32616
  function resolveComponentHostEntryForFunction(graph, fn) {
32562
32617
  let entry = null;
32618
+ let hostElementRefAgreed = true;
32563
32619
  const bodyEntry = resolveHostEntryFromFunctionBody(graph, fn);
32564
32620
  if (bodyEntry !== null) {
32565
32621
  entry = bodyEntry;
@@ -32575,9 +32631,17 @@ function resolveComponentHostEntryForFunction(graph, fn) {
32575
32631
  entry = returnEntry;
32576
32632
  continue;
32577
32633
  }
32578
- if (areComponentHostEntriesEqual(entry, returnEntry)) continue;
32634
+ if (areComponentHostEntriesEqual(entry, returnEntry)) {
32635
+ if (hostElementRefAgreed && entry.resolution === "resolved" && returnEntry.resolution === "resolved" && entry.hostElementRef !== returnEntry.hostElementRef) {
32636
+ hostElementRefAgreed = false;
32637
+ }
32638
+ continue;
32639
+ }
32579
32640
  return null;
32580
32641
  }
32642
+ if (!hostElementRefAgreed && entry !== null && entry.resolution === "resolved") {
32643
+ return { resolution: "resolved", descriptor: entry.descriptor, hostElementRef: null };
32644
+ }
32581
32645
  return entry;
32582
32646
  }
32583
32647
  function resolveHostEntryFromFunctionBody(graph, fn) {
@@ -32605,7 +32669,8 @@ function resolveHostEntryFromJSXElement(graph, node) {
32605
32669
  staticAttributes: collectStaticAttributes(element),
32606
32670
  staticClassTokens: getStaticClassTokensForElementEntity(graph, element),
32607
32671
  forwardsChildren: detectChildrenForwarding(element)
32608
- }
32672
+ },
32673
+ hostElementRef: { solid: graph, element }
32609
32674
  };
32610
32675
  }
32611
32676
  if (isContextProviderTag(element.tag)) {
@@ -33315,7 +33380,7 @@ function matchesChain(matcher, node, index, perf, fileRootElements, logger) {
33315
33380
  ancestor = ancestor.parentElementNode;
33316
33381
  }
33317
33382
  if (fileRootElements !== null) {
33318
- if (logger.enabled) {
33383
+ if (logger.isLevelEnabled(Level.Trace)) {
33319
33384
  const compoundDesc = describeCompound(targetCompound);
33320
33385
  logger.trace(`[selector-match] fallback: node=${node.key} tag=${node.tagName} checking ${fileRootElements.length} roots for compound=${compoundDesc}`);
33321
33386
  }
@@ -33326,11 +33391,11 @@ function matchesChain(matcher, node, index, perf, fileRootElements, logger) {
33326
33391
  if (root.solidFile !== node.solidFile) continue;
33327
33392
  perf.ancestryChecks++;
33328
33393
  const compoundResult = matchesCompound(root, targetCompound);
33329
- if (logger.enabled && compoundResult === "no-match") {
33394
+ if (logger.isLevelEnabled(Level.Trace) && compoundResult === "no-match") {
33330
33395
  logger.trace(`[selector-match] fallback MISS: root=${root.key} tag=${root.tagName} attrs=[${[...root.attributes.entries()].map(([k, v]) => `${k}=${v}`).join(",")}]`);
33331
33396
  }
33332
33397
  if (compoundResult !== "no-match") {
33333
- if (logger.enabled) {
33398
+ if (logger.isLevelEnabled(Level.Debug)) {
33334
33399
  const compoundDesc = describeCompound(targetCompound);
33335
33400
  logger.debug(`[selector-match] fallback HIT: node=${node.key} tag=${node.tagName} matched root=${root.key} tag=${root.tagName} compound=${compoundDesc} isFinal=${isFinal}`);
33336
33401
  }
@@ -36532,7 +36597,7 @@ function appendMatchingEdgesFromSelectorIds(ctx, selectorIds, node, applies, app
36532
36597
  };
36533
36598
  applies.push(edge);
36534
36599
  ctx.perf.matchEdgesCreated++;
36535
- if (ctx.logger.enabled) {
36600
+ if (ctx.logger.isLevelEnabled(Level.Trace)) {
36536
36601
  ctx.logger.trace(
36537
36602
  `[cascade] edge node=${node.key} selector=${selector.id} match=${matchResult} conditional=${edge.conditionalMatch} selector-raw=${selector.raw.slice(0, 80)}`
36538
36603
  );
@@ -36975,7 +37040,7 @@ function getTextualContentState(element, memo, compositionMetaByElementId, logge
36975
37040
  if (!child) continue;
36976
37041
  if (child.kind === "expression") {
36977
37042
  if (isStructuralExpression(child.node)) {
36978
- if (logger.enabled) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id} \u2192 unknown (structural expression child)`);
37043
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id} \u2192 unknown (structural expression child)`);
36979
37044
  memo.set(element.id, 2 /* Unknown */);
36980
37045
  return 2 /* Unknown */;
36981
37046
  }
@@ -36997,11 +37062,11 @@ function getTextualContentState(element, memo, compositionMetaByElementId, logge
36997
37062
  if (!child.isDomElement) {
36998
37063
  const childMeta = compositionMetaByElementId.get(child.id);
36999
37064
  if (childMeta !== void 0 && isControlTag(childMeta.tagName)) {
37000
- if (logger.enabled) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id}: non-DOM child ${child.tag}#${child.id} resolves to control tag=${childMeta.tagName}, skipping`);
37065
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id}: non-DOM child ${child.tag}#${child.id} resolves to control tag=${childMeta.tagName}, skipping`);
37001
37066
  continue;
37002
37067
  }
37003
37068
  if (childState !== 1 /* No */) {
37004
- if (logger.enabled) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id}: non-DOM child ${child.tag ?? child.id}#${child.id} has state=${childState} \u2192 childHasUnknown`);
37069
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id}: non-DOM child ${child.tag ?? child.id}#${child.id} has state=${childState} \u2192 childHasUnknown`);
37005
37070
  childHasUnknown = true;
37006
37071
  }
37007
37072
  continue;
@@ -37014,12 +37079,12 @@ function getTextualContentState(element, memo, compositionMetaByElementId, logge
37014
37079
  if (childState === 3 /* DynamicText */) childHasDynamicText = true;
37015
37080
  }
37016
37081
  if (childHasUnknown) {
37017
- if (logger.enabled) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id} \u2192 unknown (child has unknown)`);
37082
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id} \u2192 unknown (child has unknown)`);
37018
37083
  memo.set(element.id, 2 /* Unknown */);
37019
37084
  return 2 /* Unknown */;
37020
37085
  }
37021
37086
  if (hasTextOnlyExpression || childHasDynamicText) {
37022
- if (logger.enabled) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id} \u2192 dynamic-text`);
37087
+ if (logger.isLevelEnabled(Level.Trace)) logger.trace(`[textual-content] element=${element.tagName ?? element.tag}#${element.id} \u2192 dynamic-text`);
37023
37088
  memo.set(element.id, 3 /* DynamicText */);
37024
37089
  return 3 /* DynamicText */;
37025
37090
  }
@@ -37041,15 +37106,16 @@ function collectLayoutElementRecordsForSolid(solid, selectorRequirements, inline
37041
37106
  const meta = compositionMetaByElementId.get(element.id);
37042
37107
  if (!meta || !meta.participates) continue;
37043
37108
  const localClassTokens = selectorRequirements.needsClassTokens ? getStaticClassTokensForElementEntity(solid, element) : EMPTY_STRING_LIST3;
37044
- const classTokens = mergeClassTokens(localClassTokens, meta.hostDescriptor?.staticClassTokens);
37109
+ const classTokens = mergeClassTokens(localClassTokens, meta.resolvedHost?.descriptor.staticClassTokens);
37045
37110
  const classTokenSet = classTokens.length === 0 ? EMPTY_CLASS_TOKEN_SET : createClassTokenSet(classTokens);
37046
37111
  const inlineStyleKeys = getStaticStyleKeysForElement(solid, element.id);
37047
37112
  const localAttributes = selectorRequirements.needsAttributes ? collectStaticAttributes(element) : EMPTY_ATTRIBUTES2;
37048
- const attributes = mergeAttributes(localAttributes, meta.hostDescriptor?.staticAttributes);
37113
+ const attributes = mergeAttributes(localAttributes, meta.resolvedHost?.descriptor.staticAttributes);
37049
37114
  const selectorDispatchKeys = buildSelectorDispatchKeys(attributes, classTokens);
37050
37115
  const inlineStyleValues = inlineStyleValuesByElementId.get(element.id) ?? EMPTY_INLINE_STYLE_VALUES;
37051
37116
  const textualContent = getTextualContentState(element, textContentMemo, compositionMetaByElementId, logger);
37052
37117
  const parentElementId = resolveComposedParentElementId(element, compositionMetaByElementId);
37118
+ const hostElementRef = meta.resolvedHost?.hostElementRef ?? null;
37053
37119
  out.push({
37054
37120
  element,
37055
37121
  key: toLayoutElementKey(solid.file, element.id),
@@ -37062,7 +37128,8 @@ function collectLayoutElementRecordsForSolid(solid, selectorRequirements, inline
37062
37128
  selectorDispatchKeys,
37063
37129
  inlineStyleValues,
37064
37130
  textualContent,
37065
- parentElementId
37131
+ parentElementId,
37132
+ hostElementRef
37066
37133
  });
37067
37134
  }
37068
37135
  return out;
@@ -37072,7 +37139,7 @@ function collectCompositionMetaByElementId(solid, componentHostResolver) {
37072
37139
  for (let i = 0; i < solid.jsxElements.length; i++) {
37073
37140
  const element = solid.jsxElements[i];
37074
37141
  if (!element) continue;
37075
- const hostDescriptor = resolveHostDescriptorForElement(
37142
+ const resolvedHost = resolveHostForElement(
37076
37143
  componentHostResolver,
37077
37144
  solid.file,
37078
37145
  element
@@ -37081,30 +37148,30 @@ function collectCompositionMetaByElementId(solid, componentHostResolver) {
37081
37148
  componentHostResolver,
37082
37149
  solid.file,
37083
37150
  element,
37084
- hostDescriptor
37151
+ resolvedHost
37085
37152
  );
37086
37153
  const participates = element.tag !== null && !isTransparentPrimitive;
37087
- const tag = resolveEffectiveTag(element, hostDescriptor);
37154
+ const tag = resolveEffectiveTag(element, resolvedHost?.descriptor ?? null);
37088
37155
  const tagName = tag ? tag.toLowerCase() : null;
37089
37156
  out.set(element.id, {
37090
37157
  element,
37091
37158
  participates,
37092
37159
  tag,
37093
37160
  tagName,
37094
- hostDescriptor
37161
+ resolvedHost
37095
37162
  });
37096
37163
  }
37097
37164
  return out;
37098
37165
  }
37099
- function resolveHostDescriptorForElement(componentHostResolver, solidFile, element) {
37166
+ function resolveHostForElement(componentHostResolver, solidFile, element) {
37100
37167
  if (element.tag === null) return null;
37101
37168
  if (element.isDomElement) return null;
37102
37169
  return componentHostResolver.resolveHost(solidFile, element.tag);
37103
37170
  }
37104
- function resolveTransparentPrimitiveStatus(componentHostResolver, solidFile, element, hostDescriptor) {
37171
+ function resolveTransparentPrimitiveStatus(componentHostResolver, solidFile, element, resolvedHost) {
37105
37172
  if (element.tag === null) return false;
37106
37173
  if (element.isDomElement) return false;
37107
- if (hostDescriptor !== null) return false;
37174
+ if (resolvedHost !== null) return false;
37108
37175
  return componentHostResolver.isTransparentPrimitive(solidFile, element.tag);
37109
37176
  }
37110
37177
  function resolveEffectiveTag(element, hostDescriptor) {
@@ -37222,6 +37289,7 @@ function buildLayoutGraph(solids, css, logger = noopLogger) {
37222
37289
  const childrenByParentNodeMutable = /* @__PURE__ */ new Map();
37223
37290
  const elementBySolidFileAndIdMutable = /* @__PURE__ */ new Map();
37224
37291
  const elementRefsBySolidFileAndIdMutable = /* @__PURE__ */ new Map();
37292
+ const hostElementRefsByNodeMutable = /* @__PURE__ */ new Map();
37225
37293
  const appliesByElementNodeMutable = /* @__PURE__ */ new Map();
37226
37294
  const selectorsById = /* @__PURE__ */ new Map();
37227
37295
  const monitoredDeclarationsBySelectorId = /* @__PURE__ */ new Map();
@@ -37258,7 +37326,7 @@ function buildLayoutGraph(solids, css, logger = noopLogger) {
37258
37326
  const moduleResolver = createLayoutModuleResolver(solids, css);
37259
37327
  const componentHostResolver = createLayoutComponentHostResolver(solids, moduleResolver, logger);
37260
37328
  const cssScopeBySolidFile = collectCSSScopeBySolidFile(solids, css, moduleResolver);
37261
- if (logger.enabled) {
37329
+ if (logger.isLevelEnabled(Level.Trace)) {
37262
37330
  for (const [solidFile, scopePaths] of cssScopeBySolidFile) {
37263
37331
  if (scopePaths.length > 0) {
37264
37332
  let names = "";
@@ -37353,6 +37421,9 @@ function buildLayoutGraph(solids, css, logger = noopLogger) {
37353
37421
  isControl: isControlTag(record.tagName),
37354
37422
  isReplaced: isReplacedTag(record.tagName)
37355
37423
  };
37424
+ if (record.hostElementRef !== null) {
37425
+ hostElementRefsByNodeMutable.set(node, record.hostElementRef);
37426
+ }
37356
37427
  elements.push(node);
37357
37428
  elementById.set(record.element.id, node);
37358
37429
  nodeByElementId.set(record.element.id, node);
@@ -37374,7 +37445,7 @@ function buildLayoutGraph(solids, css, logger = noopLogger) {
37374
37445
  }
37375
37446
  }
37376
37447
  }
37377
- if (logger.enabled) {
37448
+ if (logger.isLevelEnabled(Level.Debug)) {
37378
37449
  for (const [file, roots] of rootElementsByFile) {
37379
37450
  const descs = roots.map((r) => `${r.key}(tag=${r.tagName}, attrs=[${[...r.attributes.entries()].map(([k, v]) => `${k}=${v}`).join(",")}])`);
37380
37451
  logger.debug(`[build] rootElementsByFile file=${file} count=${roots.length}: ${descs.join(", ")}`);
@@ -37417,7 +37488,7 @@ function buildLayoutGraph(solids, css, logger = noopLogger) {
37417
37488
  appliesByNode.set(node, edges);
37418
37489
  }
37419
37490
  perf.cascadeBuildMs = performance.now() - cascadeStartedAt;
37420
- if (logger.enabled) {
37491
+ if (logger.isLevelEnabled(Level.Trace)) {
37421
37492
  for (let i = 0; i < elements.length; i++) {
37422
37493
  const node = elements[i];
37423
37494
  if (!node) continue;
@@ -37473,6 +37544,7 @@ function buildLayoutGraph(solids, css, logger = noopLogger) {
37473
37544
  childrenByParentNode: childrenByParentNodeMutable,
37474
37545
  elementBySolidFileAndId: elementBySolidFileAndIdMutable,
37475
37546
  elementRefsBySolidFileAndId: elementRefsBySolidFileAndIdMutable,
37547
+ hostElementRefsByNode: hostElementRefsByNodeMutable,
37476
37548
  appliesByNode,
37477
37549
  selectorCandidatesByNode,
37478
37550
  selectorsById,
@@ -37873,7 +37945,7 @@ function computeFlowParticipationFact(snapshot) {
37873
37945
  }
37874
37946
  function buildContextIndex(childrenByParentNode, snapshotByElementNode, perf, logger) {
37875
37947
  const out = /* @__PURE__ */ new Map();
37876
- const trace = logger.enabled;
37948
+ const trace = logger.isLevelEnabled(Level.Trace);
37877
37949
  for (const [parent, children] of childrenByParentNode) {
37878
37950
  if (children.length < 2) continue;
37879
37951
  const snapshot = snapshotByElementNode.get(parent);
@@ -38692,7 +38764,7 @@ function runLayoutDetector(context, detector) {
38692
38764
  result.evidence.posteriorLower,
38693
38765
  result.evidence.posteriorUpper
38694
38766
  );
38695
- if (log.enabled) {
38767
+ if (log.isLevelEnabled(Level.Debug)) {
38696
38768
  log.debug(
38697
38769
  `[${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("; ")}]`
38698
38770
  );
@@ -38701,7 +38773,7 @@ function runLayoutDetector(context, detector) {
38701
38773
  continue;
38702
38774
  }
38703
38775
  recordPolicyMetrics(context, result.evidenceMass, result.posteriorLower, result.posteriorUpper);
38704
- if (log.enabled) {
38776
+ if (log.isLevelEnabled(Level.Debug)) {
38705
38777
  log.debug(
38706
38778
  `[${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)}`
38707
38779
  );
@@ -39329,13 +39401,39 @@ var INLINE_TOUCH_TARGET_KEYS = /* @__PURE__ */ new Set([
39329
39401
  "height",
39330
39402
  "min-height",
39331
39403
  "width",
39332
- "min-width",
39333
- "padding-left",
39334
- "padding-right",
39335
- "padding-inline",
39336
- "padding-inline-start",
39337
- "padding-inline-end"
39404
+ "min-width"
39338
39405
  ]);
39406
+ var INTERACTIVE_HTML_TAGS = /* @__PURE__ */ new Set(["button", "a", "input", "select", "textarea", "label", "summary"]);
39407
+ var INTERACTIVE_ARIA_ROLES = /* @__PURE__ */ new Set([
39408
+ "button",
39409
+ "link",
39410
+ "checkbox",
39411
+ "radio",
39412
+ "combobox",
39413
+ "listbox",
39414
+ "menuitem",
39415
+ "menuitemcheckbox",
39416
+ "menuitemradio",
39417
+ "option",
39418
+ "switch",
39419
+ "tab"
39420
+ ]);
39421
+ function isInteractiveElement(solid, element, hostElementRef) {
39422
+ if (element.tagName !== null && INTERACTIVE_HTML_TAGS.has(element.tagName)) return true;
39423
+ const roleAttr = getJSXAttributeEntity(solid, element, "role");
39424
+ if (roleAttr !== null && roleAttr.valueNode !== null) {
39425
+ const role = getStaticStringFromJSXValue(roleAttr.valueNode);
39426
+ if (role !== null && INTERACTIVE_ARIA_ROLES.has(role)) return true;
39427
+ }
39428
+ if (hostElementRef !== null && hostElementRef.element.tagName !== null) {
39429
+ if (INTERACTIVE_HTML_TAGS.has(hostElementRef.element.tagName)) return true;
39430
+ }
39431
+ return false;
39432
+ }
39433
+ function readNodeHostElementRef(layout, solid, element) {
39434
+ const node = layout.elementBySolidFileAndId.get(solid.file)?.get(element.id) ?? null;
39435
+ return node !== null ? readHostElementRef(layout, node) : null;
39436
+ }
39339
39437
  var jsxStylePolicy = defineCrossRule({
39340
39438
  id: "jsx-style-policy",
39341
39439
  severity: "warn",
@@ -39346,11 +39444,11 @@ var jsxStylePolicy = defineCrossRule({
39346
39444
  category: "css-jsx"
39347
39445
  },
39348
39446
  check(context, emit) {
39349
- const { solids } = context;
39447
+ const { solids, layout } = context;
39350
39448
  const policy = getActivePolicy();
39351
39449
  if (policy === null) return;
39352
39450
  const name = getActivePolicyName() ?? "";
39353
- forEachStylePropertyAcross(solids, (solid, p) => {
39451
+ forEachStylePropertyAcross(solids, (solid, p, element) => {
39354
39452
  if (!import_typescript135.default.isPropertyAssignment(p)) return;
39355
39453
  const key = objectKeyName(p.name);
39356
39454
  if (!key) return;
@@ -39398,6 +39496,8 @@ var jsxStylePolicy = defineCrossRule({
39398
39496
  return;
39399
39497
  }
39400
39498
  if (INLINE_TOUCH_TARGET_KEYS.has(normalizedKey)) {
39499
+ const hostRef = readNodeHostElementRef(layout, solid, element);
39500
+ if (!isInteractiveElement(solid, element, hostRef)) return;
39401
39501
  const strVal = getStaticStringValue(p.initializer);
39402
39502
  if (!strVal) return;
39403
39503
  const px = parsePxValue(strVal);
@@ -39476,7 +39576,7 @@ var siblingAlignmentDetector = {
39476
39576
  id: "sibling-alignment-outlier",
39477
39577
  collect: collectAlignmentCases,
39478
39578
  evaluate(input, context) {
39479
- if (context.logger.enabled) {
39579
+ if (context.logger.isLevelEnabled(Level.Trace)) {
39480
39580
  const ctx = input.context;
39481
39581
  context.logger.trace(
39482
39582
  `[sibling-alignment] evaluate subject=${input.subject.elementKey} tag=${input.subject.tag} parent=${ctx.parentElementKey} parentTag=${ctx.parentTag} context.kind=${ctx.kind} certainty=${ctx.certainty} display=${ctx.parentDisplay} alignItems=${ctx.parentAlignItems} crossAxisIsBlockAxis=${ctx.crossAxisIsBlockAxis} crossAxisCertainty=${ctx.crossAxisIsBlockAxisCertainty} baseline=${ctx.baselineRelevance}`
@@ -39525,7 +39625,7 @@ var cssLayoutSiblingAlignmentOutlier = defineCrossRule({
39525
39625
  const log = context.logger;
39526
39626
  const detections = runLayoutDetector(context, siblingAlignmentDetector);
39527
39627
  const uniqueDetections = dedupeDetectionsBySubject(detections);
39528
- if (log.enabled) {
39628
+ if (log.isLevelEnabled(Level.Debug)) {
39529
39629
  log.debug(
39530
39630
  `[sibling-alignment] raw=${detections.length} deduped=${uniqueDetections.length}`
39531
39631
  );
@@ -39539,7 +39639,7 @@ var cssLayoutSiblingAlignmentOutlier = defineCrossRule({
39539
39639
  const subjectId = detection.caseData.subject.elementId;
39540
39640
  const logPrefix = `[sibling-alignment] <${subjectTag}> in <${parentTag}> (${subjectFile}#${subjectId})`;
39541
39641
  if (detection.evidence.confidence < MIN_CONFIDENCE_THRESHOLD) {
39542
- if (log.enabled) {
39642
+ if (log.isLevelEnabled(Level.Debug)) {
39543
39643
  log.debug(
39544
39644
  `${logPrefix} SKIP: confidence=${detection.evidence.confidence.toFixed(2)} < threshold=${MIN_CONFIDENCE_THRESHOLD}`
39545
39645
  );
@@ -39548,7 +39648,7 @@ var cssLayoutSiblingAlignmentOutlier = defineCrossRule({
39548
39648
  }
39549
39649
  const estimatedOffset = detection.evidence.estimatedOffsetPx;
39550
39650
  if (estimatedOffset !== null && Math.abs(estimatedOffset) < MIN_OFFSET_PX_THRESHOLD && !hasNonOffsetPrimaryEvidence(detection.evidence.topFactors)) {
39551
- if (log.enabled) {
39651
+ if (log.isLevelEnabled(Level.Debug)) {
39552
39652
  log.debug(
39553
39653
  `${logPrefix} SKIP: offset=${estimatedOffset.toFixed(2)}px < ${MIN_OFFSET_PX_THRESHOLD}px (no non-offset primary evidence, topFactors=[${detection.evidence.topFactors.join(",")}])`
39554
39654
  );
@@ -39560,7 +39660,7 @@ var cssLayoutSiblingAlignmentOutlier = defineCrossRule({
39560
39660
  detection.caseData.cohort.parentElementKey,
39561
39661
  detection.caseData.subject.solidFile
39562
39662
  )) {
39563
- if (log.enabled) {
39663
+ if (log.isLevelEnabled(Level.Debug)) {
39564
39664
  log.debug(`${logPrefix} SKIP: out-of-flow ancestor`);
39565
39665
  }
39566
39666
  continue;
@@ -39571,7 +39671,7 @@ var cssLayoutSiblingAlignmentOutlier = defineCrossRule({
39571
39671
  detection.caseData.subject.elementId
39572
39672
  );
39573
39673
  if (!subjectRef) {
39574
- if (log.enabled) {
39674
+ if (log.isLevelEnabled(Level.Debug)) {
39575
39675
  log.debug(`${logPrefix} SKIP: no node ref`);
39576
39676
  }
39577
39677
  continue;
@@ -39587,7 +39687,7 @@ var cssLayoutSiblingAlignmentOutlier = defineCrossRule({
39587
39687
  const primaryFix = detection.evidence.primaryFix;
39588
39688
  const firstChar = primaryFix.length > 0 ? primaryFix[0] : void 0;
39589
39689
  const fix = firstChar !== void 0 ? ` ${firstChar.toUpperCase()}${primaryFix.slice(1)}.` : "";
39590
- if (log.enabled) {
39690
+ if (log.isLevelEnabled(Level.Debug)) {
39591
39691
  log.debug(
39592
39692
  `${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}]`
39593
39693
  );
@@ -39996,7 +40096,8 @@ var cssLayoutUnsizedReplacedElement = defineCrossRule({
39996
40096
  const ref = readNodeRef(context.layout, node);
39997
40097
  if (!ref) continue;
39998
40098
  const reservedSpace = readReservedSpaceFact(context.layout, node);
39999
- if (hasReservedSize(ref.solid, node.attributes, ref.element, reservedSpace)) continue;
40099
+ const hostRef = readHostElementRef(context.layout, node);
40100
+ if (hasReservedSize(ref.solid, node.attributes, ref.element, reservedSpace, hostRef)) continue;
40000
40101
  emit(
40001
40102
  createDiagnostic(
40002
40103
  ref.solid.file,
@@ -40011,15 +40112,17 @@ var cssLayoutUnsizedReplacedElement = defineCrossRule({
40011
40112
  }
40012
40113
  }
40013
40114
  });
40014
- function hasReservedSize(solid, attributes, element, reservedSpaceFact) {
40115
+ function hasReservedSize(solid, attributes, element, reservedSpaceFact, hostElementRef) {
40015
40116
  if (reservedSpaceFact.hasReservedSpace) return true;
40016
40117
  const attrWidth = parsePositiveLength(attributes.get("width"));
40017
40118
  const attrHeight = parsePositiveLength(attributes.get("height"));
40018
40119
  const jsxAttrWidth = readPositiveJsxAttribute(solid, element, "width");
40019
40120
  const jsxAttrHeight = readPositiveJsxAttribute(solid, element, "height");
40020
- if (attrWidth && attrHeight || jsxAttrWidth && jsxAttrHeight) return true;
40021
- const hasAnyWidth = attrWidth || jsxAttrWidth || reservedSpaceFact.hasUsableInlineDimension;
40022
- const hasAnyHeight = attrHeight || jsxAttrHeight || reservedSpaceFact.hasUsableBlockDimension || reservedSpaceFact.hasContainIntrinsicSize;
40121
+ const hostJsxWidth = hostElementRef !== null ? readPositiveJsxAttribute(hostElementRef.solid, hostElementRef.element, "width") : false;
40122
+ const hostJsxHeight = hostElementRef !== null ? readPositiveJsxAttribute(hostElementRef.solid, hostElementRef.element, "height") : false;
40123
+ if (attrWidth && attrHeight || jsxAttrWidth && jsxAttrHeight || hostJsxWidth && hostJsxHeight) return true;
40124
+ const hasAnyWidth = attrWidth || jsxAttrWidth || hostJsxWidth || reservedSpaceFact.hasUsableInlineDimension;
40125
+ const hasAnyHeight = attrHeight || jsxAttrHeight || hostJsxHeight || reservedSpaceFact.hasUsableBlockDimension || reservedSpaceFact.hasContainIntrinsicSize;
40023
40126
  if (reservedSpaceFact.hasUsableAspectRatio && (hasAnyWidth || hasAnyHeight)) return true;
40024
40127
  if (reservedSpaceFact.hasContainIntrinsicSize && (hasAnyWidth || hasAnyHeight)) return true;
40025
40128
  return false;