@nmakarov/cli-toolkit 0.36.0 → 0.37.0

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.cjs CHANGED
@@ -1983,11 +1983,14 @@ var Params = class _Params {
1983
1983
  * Attribution rules:
1984
1984
  * - entries figured from an explicit input (cli/env/options/…) are left
1985
1985
  * untouched — the component merely confirmed them, the origin stands;
1986
- * - entries whose source is "default" (Params had nothing) are upgraded
1987
- * in place to the reported value and source;
1986
+ * - "default" entries (Params had nothing) and earlier reports are
1987
+ * replaced by the report;
1988
1988
  * - keys never seen by Params are appended as new entries.
1989
- * First report wins: once upgraded, later reports for the same key/module
1990
- * are ignored (the source is no longer "default").
1989
+ * The LATEST report wins a component may resolve the same key several
1990
+ * times with increasing specificity (e.g. a blueprint re-merged for a
1991
+ * concrete resource) and the dump should show what it settled on.
1992
+ * Later params.get() probes that find nothing ("default") never shadow a
1993
+ * reported value — see {@link getFiguredByModule}.
1991
1994
  *
1992
1995
  * @param {string} key
1993
1996
  * @param {*} value - the value the component actually uses
@@ -1997,17 +2000,20 @@ var Params = class _Params {
1997
2000
  reportResolved(key, value, source = "discovered", moduleName) {
1998
2001
  const mod = moduleName ?? this._currentModule;
1999
2002
  const mine = this.trackedParams.filter((e) => e.key === key && e.module === mod);
2000
- if (mine.some((e) => e.source !== "default")) {
2003
+ if (mine.some((e) => e.source !== "default" && !e.reported)) {
2001
2004
  return;
2002
2005
  }
2003
- if (mine.length === 0) {
2004
- this.trackParam(key, "reported", value, source, mod);
2005
- return;
2006
- }
2007
- for (const entry of mine) {
2008
- entry.value = value;
2009
- entry.source = source;
2010
- }
2006
+ this.trackedParams = this.trackedParams.filter(
2007
+ (e) => !(e.key === key && e.module === mod)
2008
+ );
2009
+ this.trackedParams.push({
2010
+ key,
2011
+ definition: "reported",
2012
+ value,
2013
+ source,
2014
+ module: mod,
2015
+ reported: true
2016
+ });
2011
2017
  }
2012
2018
  /**
2013
2019
  * Get all tracked parameters (for --stopAfter=init)
@@ -2033,12 +2039,24 @@ var Params = class _Params {
2033
2039
  /**
2034
2040
  * Get figured parameters grouped by module name.
2035
2041
  * Same param can appear in multiple modules (e.g. source, resource).
2042
+ * Last occurrence per key wins, EXCEPT that an empty probe — a
2043
+ * params.get() that found nothing ("default", undefined) — never shadows
2044
+ * a value reported via {@link reportResolved}: components probe for
2045
+ * overrides on every resolution cycle, and those misses say nothing about
2046
+ * the value the component actually uses.
2036
2047
  */
2037
2048
  getFiguredByModule() {
2049
+ const reported = /* @__PURE__ */ new Set();
2050
+ for (const param of this.trackedParams) {
2051
+ if (param.reported) reported.add(`${param.module}\0${param.key}`);
2052
+ }
2038
2053
  const byModule = {};
2039
2054
  for (const param of this.trackedParams) {
2040
2055
  const mod = param.module;
2041
2056
  if (!byModule[mod]) byModule[mod] = {};
2057
+ if (!param.reported && param.source === "default" && reported.has(`${mod}\0${param.key}`)) {
2058
+ continue;
2059
+ }
2042
2060
  byModule[mod][param.key] = { value: param.value, source: param.source };
2043
2061
  }
2044
2062
  return byModule;