@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.
@@ -1863,11 +1863,14 @@ var Params = class _Params {
1863
1863
  * Attribution rules:
1864
1864
  * - entries figured from an explicit input (cli/env/options/…) are left
1865
1865
  * untouched — the component merely confirmed them, the origin stands;
1866
- * - entries whose source is "default" (Params had nothing) are upgraded
1867
- * in place to the reported value and source;
1866
+ * - "default" entries (Params had nothing) and earlier reports are
1867
+ * replaced by the report;
1868
1868
  * - keys never seen by Params are appended as new entries.
1869
- * First report wins: once upgraded, later reports for the same key/module
1870
- * are ignored (the source is no longer "default").
1869
+ * The LATEST report wins a component may resolve the same key several
1870
+ * times with increasing specificity (e.g. a blueprint re-merged for a
1871
+ * concrete resource) and the dump should show what it settled on.
1872
+ * Later params.get() probes that find nothing ("default") never shadow a
1873
+ * reported value — see {@link getFiguredByModule}.
1871
1874
  *
1872
1875
  * @param {string} key
1873
1876
  * @param {*} value - the value the component actually uses
@@ -1877,17 +1880,20 @@ var Params = class _Params {
1877
1880
  reportResolved(key, value, source = "discovered", moduleName) {
1878
1881
  const mod = moduleName ?? this._currentModule;
1879
1882
  const mine = this.trackedParams.filter((e) => e.key === key && e.module === mod);
1880
- if (mine.some((e) => e.source !== "default")) {
1883
+ if (mine.some((e) => e.source !== "default" && !e.reported)) {
1881
1884
  return;
1882
1885
  }
1883
- if (mine.length === 0) {
1884
- this.trackParam(key, "reported", value, source, mod);
1885
- return;
1886
- }
1887
- for (const entry of mine) {
1888
- entry.value = value;
1889
- entry.source = source;
1890
- }
1886
+ this.trackedParams = this.trackedParams.filter(
1887
+ (e) => !(e.key === key && e.module === mod)
1888
+ );
1889
+ this.trackedParams.push({
1890
+ key,
1891
+ definition: "reported",
1892
+ value,
1893
+ source,
1894
+ module: mod,
1895
+ reported: true
1896
+ });
1891
1897
  }
1892
1898
  /**
1893
1899
  * Get all tracked parameters (for --stopAfter=init)
@@ -1913,12 +1919,24 @@ var Params = class _Params {
1913
1919
  /**
1914
1920
  * Get figured parameters grouped by module name.
1915
1921
  * Same param can appear in multiple modules (e.g. source, resource).
1922
+ * Last occurrence per key wins, EXCEPT that an empty probe — a
1923
+ * params.get() that found nothing ("default", undefined) — never shadows
1924
+ * a value reported via {@link reportResolved}: components probe for
1925
+ * overrides on every resolution cycle, and those misses say nothing about
1926
+ * the value the component actually uses.
1916
1927
  */
1917
1928
  getFiguredByModule() {
1929
+ const reported = /* @__PURE__ */ new Set();
1930
+ for (const param of this.trackedParams) {
1931
+ if (param.reported) reported.add(`${param.module}\0${param.key}`);
1932
+ }
1918
1933
  const byModule = {};
1919
1934
  for (const param of this.trackedParams) {
1920
1935
  const mod = param.module;
1921
1936
  if (!byModule[mod]) byModule[mod] = {};
1937
+ if (!param.reported && param.source === "default" && reported.has(`${mod}\0${param.key}`)) {
1938
+ continue;
1939
+ }
1922
1940
  byModule[mod][param.key] = { value: param.value, source: param.source };
1923
1941
  }
1924
1942
  return byModule;