@player-ui/partial-match-registry 0.15.3 → 0.15.4--canary.881.37421

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.
@@ -81,6 +81,23 @@ function _unsupported_iterable_to_array(o, minLen) {
81
81
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
82
82
  }
83
83
  var Registry = function() {
84
+ var createNewSortInstance = function createNewSortInstance(opts) {
85
+ var comparer = castComparer(opts.comparer);
86
+ return function(arrayToSort) {
87
+ var ctx = Array.isArray(arrayToSort) && !opts.inPlaceSorting ? arrayToSort.slice() : arrayToSort;
88
+ return {
89
+ asc: function asc(sortBy) {
90
+ return sortArray(1, ctx, sortBy, comparer);
91
+ },
92
+ desc: function desc(sortBy) {
93
+ return sortArray(-1, ctx, sortBy, comparer);
94
+ },
95
+ by: function by(sortBy) {
96
+ return sortArray(1, ctx, sortBy, comparer);
97
+ }
98
+ };
99
+ };
100
+ };
84
101
  var dlv_es_default = // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js
85
102
  function dlv_es_default(t, e, l, n, r) {
86
103
  for(e = e.split ? e.split(".") : e, n = 0; n < e.length; n++)t = t ? t[e[n]] : r;
@@ -88,7 +105,7 @@ var Registry = function() {
88
105
  };
89
106
  var createObjectMatcher = function createObjectMatcher(partialObj) {
90
107
  var pairs = traverseObj(partialObj);
91
- var matchFunction = function matchFunction(searchObj) {
108
+ var matchFunction = function(searchObj) {
92
109
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
93
110
  try {
94
111
  for(var _iterator = Array.from(pairs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
@@ -119,39 +136,30 @@ var Registry = function() {
119
136
  };
120
137
  var createBasicMatcher = // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts
121
138
  function createBasicMatcher(seed) {
122
- var matcher = function matcher(match) {
139
+ var matcher = function(match) {
123
140
  return seed === match;
124
141
  };
125
142
  matcher.count = 1;
126
143
  return matcher;
127
144
  };
128
- var __create = Object.create;
129
145
  var __defProp = Object.defineProperty;
130
146
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
131
147
  var __getOwnPropNames = Object.getOwnPropertyNames;
132
- var __getProtoOf = Object.getPrototypeOf;
133
148
  var __hasOwnProp = Object.prototype.hasOwnProperty;
134
- var __commonJS = function __commonJS(cb, mod) {
135
- return function __require() {
136
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
137
- exports: {}
138
- }).exports, mod), mod.exports;
139
- };
140
- };
141
- var __export = function __export(target, all) {
149
+ var __export = function(target, all) {
142
150
  for(var name in all)__defProp(target, name, {
143
151
  get: all[name],
144
152
  enumerable: true
145
153
  });
146
154
  };
147
- var __copyProps = function __copyProps(to, from, except, desc) {
155
+ var __copyProps = function(to, from, except, desc) {
148
156
  if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
149
157
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
150
158
  try {
151
159
  var _loop = function() {
152
160
  var key = _step.value;
153
161
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
154
- get: function get() {
162
+ get: function() {
155
163
  return from[key];
156
164
  },
157
165
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -175,113 +183,117 @@ var Registry = function() {
175
183
  }
176
184
  return to;
177
185
  };
178
- var __toESM = function __toESM(mod, isNodeMode, target) {
179
- return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
180
- // file that has been converted to a CommonJS file using a Babel-
181
- // compatible transform (i.e. "__esModule" has not been set), then set
182
- // "default" to the CommonJS "module.exports" for node compatibility.
183
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
184
- value: mod,
185
- enumerable: true
186
- }) : target, mod);
187
- };
188
- var __toCommonJS = function __toCommonJS(mod) {
186
+ var __toCommonJS = function(mod) {
189
187
  return __copyProps(__defProp({}, "__esModule", {
190
188
  value: true
191
189
  }), mod);
192
190
  };
193
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js
194
- var require_sorted_array = __commonJS({
195
- "../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js": function(exports, module) {
196
- "use strict";
197
- var SortedArray2 = function() {
198
- var SortedArray3 = defclass({
199
- constructor: function constructor(array, compare) {
200
- this.array = [];
201
- this.compare = compare || compareDefault;
202
- var length = array.length, index = 0;
203
- while(index < length)this.insert(array[index++]);
204
- },
205
- insert: function insert(element) {
206
- var array = this.array, compare = this.compare, high = array.length - 1, low = 0, pos = -1, index, ordering;
207
- while(high >= low){
208
- index = (high + low) / 2 >>> 0;
209
- ordering = compare(array[index], element);
210
- if (ordering < 0) low = index + 1;
211
- else if (ordering > 0) high = index - 1;
212
- else {
213
- pos = index;
214
- break;
215
- }
216
- ;
217
- }
218
- if (pos === -1) {
219
- pos = high;
220
- }
221
- pos++;
222
- high = array.length - 1;
223
- while(pos < high && compare(element, array[pos]) === 0){
224
- pos++;
225
- }
226
- index = array.length;
227
- array.push(element);
228
- while(index > pos){
229
- array[index] = array[--index];
230
- }
231
- array[pos] = element;
232
- return this;
233
- },
234
- search: function search(element) {
235
- var array = this.array, compare = this.compare, high = array.length - 1, low = 0, index, ordering;
236
- while(high >= low){
237
- index = (high + low) / 2 >>> 0;
238
- ordering = compare(array[index], element);
239
- if (ordering < 0) low = index + 1;
240
- else if (ordering > 0) high = index - 1;
241
- else return index;
242
- }
243
- return -1;
244
- },
245
- remove: function remove(element) {
246
- var index = this.search(element);
247
- if (index >= 0) this.array.splice(index, 1);
248
- return this;
249
- }
250
- });
251
- SortedArray3.comparing = function(property, array) {
252
- return new SortedArray3(array, function(a, b) {
253
- return compareDefault(a[property], b[property]);
254
- });
255
- };
256
- return SortedArray3;
257
- function defclass(prototype) {
258
- var constructor = prototype.constructor;
259
- constructor.prototype = prototype;
260
- return constructor;
261
- }
262
- function compareDefault(a, b) {
263
- if (a < b) return -1;
264
- else if (a > b) return 1;
265
- else return 0;
266
- }
267
- }();
268
- if ((typeof module === "undefined" ? "undefined" : _type_of(module)) === "object") module.exports = SortedArray2;
269
- if (typeof define === "function" && define.amd) define(function() {
270
- return SortedArray2;
271
- });
272
- }
273
- });
274
191
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts
275
192
  var src_exports = {};
276
193
  __export(src_exports, {
277
- Registry: function Registry1() {
194
+ Registry: function() {
278
195
  return Registry;
279
196
  },
280
- createObjectMatcher: function createObjectMatcher1() {
197
+ createObjectMatcher: function() {
281
198
  return createObjectMatcher;
282
199
  }
283
200
  });
284
- var import_sorted_array = __toESM(require_sorted_array());
201
+ // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/fast-sort@3.4.1/node_modules/fast-sort/dist/sort.mjs
202
+ var castComparer = function castComparer(comparer) {
203
+ return function(a, b, order) {
204
+ return comparer(a, b, order) * order;
205
+ };
206
+ };
207
+ var throwInvalidConfigErrorIfTrue = function throwInvalidConfigErrorIfTrue(condition, context) {
208
+ if (condition) throw Error("Invalid sort config: " + context);
209
+ };
210
+ var unpackObjectSorter = function unpackObjectSorter(sortByObj) {
211
+ var _a = sortByObj || {}, asc = _a.asc, desc = _a.desc;
212
+ var order = asc ? 1 : -1;
213
+ var sortBy = asc || desc;
214
+ throwInvalidConfigErrorIfTrue(!sortBy, "Expected `asc` or `desc` property");
215
+ throwInvalidConfigErrorIfTrue(asc && desc, "Ambiguous object with `asc` and `desc` config properties");
216
+ var comparer = sortByObj.comparer && castComparer(sortByObj.comparer);
217
+ return {
218
+ order: order,
219
+ sortBy: sortBy,
220
+ comparer: comparer
221
+ };
222
+ };
223
+ var multiPropertySorterProvider = function multiPropertySorterProvider(defaultComparer2) {
224
+ return function multiPropertySorter(sortBy, sortByArr, depth, order, comparer, a, b) {
225
+ var valA;
226
+ var valB;
227
+ if (typeof sortBy === "string") {
228
+ valA = a[sortBy];
229
+ valB = b[sortBy];
230
+ } else if (typeof sortBy === "function") {
231
+ valA = sortBy(a);
232
+ valB = sortBy(b);
233
+ } else {
234
+ var objectSorterConfig = unpackObjectSorter(sortBy);
235
+ return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer2, a, b);
236
+ }
237
+ var equality = comparer(valA, valB, order);
238
+ if ((equality === 0 || valA == null && valB == null) && sortByArr.length > depth) {
239
+ return multiPropertySorter(sortByArr[depth], sortByArr, depth + 1, order, comparer, a, b);
240
+ }
241
+ return equality;
242
+ };
243
+ };
244
+ function getSortStrategy(sortBy, comparer, order) {
245
+ if (sortBy === void 0 || sortBy === true) {
246
+ return function(a, b) {
247
+ return comparer(a, b, order);
248
+ };
249
+ }
250
+ if (typeof sortBy === "string") {
251
+ throwInvalidConfigErrorIfTrue(sortBy.includes("."), "String syntax not allowed for nested properties.");
252
+ return function(a, b) {
253
+ return comparer(a[sortBy], b[sortBy], order);
254
+ };
255
+ }
256
+ if (typeof sortBy === "function") {
257
+ return function(a, b) {
258
+ return comparer(sortBy(a), sortBy(b), order);
259
+ };
260
+ }
261
+ if (Array.isArray(sortBy)) {
262
+ var multiPropSorter_1 = multiPropertySorterProvider(comparer);
263
+ return function(a, b) {
264
+ return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b);
265
+ };
266
+ }
267
+ var objectSorterConfig = unpackObjectSorter(sortBy);
268
+ return getSortStrategy(objectSorterConfig.sortBy, objectSorterConfig.comparer || comparer, objectSorterConfig.order);
269
+ }
270
+ var sortArray = function sortArray(order, ctx, sortBy, comparer) {
271
+ var _a;
272
+ if (!Array.isArray(ctx)) {
273
+ return ctx;
274
+ }
275
+ if (Array.isArray(sortBy) && sortBy.length < 2) {
276
+ _a = sortBy, sortBy = _a[0];
277
+ }
278
+ return ctx.sort(getSortStrategy(sortBy, comparer, order));
279
+ };
280
+ var defaultComparer = function defaultComparer(a, b, order) {
281
+ if (a == null) return order;
282
+ if (b == null) return -order;
283
+ if ((typeof a === "undefined" ? "undefined" : _type_of(a)) !== (typeof b === "undefined" ? "undefined" : _type_of(b))) {
284
+ return (typeof a === "undefined" ? "undefined" : _type_of(a)) < (typeof b === "undefined" ? "undefined" : _type_of(b)) ? -1 : 1;
285
+ }
286
+ if (a < b) return -1;
287
+ if (a > b) return 1;
288
+ return 0;
289
+ };
290
+ var sort = createNewSortInstance({
291
+ comparer: defaultComparer
292
+ });
293
+ var inPlaceSort = createNewSortInstance({
294
+ comparer: defaultComparer,
295
+ inPlaceSorting: true
296
+ });
285
297
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts
286
298
  function traverseObj(object) {
287
299
  var path = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [], pairs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Map();
@@ -293,7 +305,7 @@ var Registry = function() {
293
305
  var nestedPath = _to_consumable_array(path).concat([
294
306
  key
295
307
  ]);
296
- if ((typeof val === "undefined" ? "undefined" : _type_of(val)) === "object") {
308
+ if ((typeof val === "undefined" ? "undefined" : _type_of(val)) === "object" && val !== null) {
297
309
  traverseObj(val, nestedPath, pairs);
298
310
  } else {
299
311
  pairs.set(nestedPath, val);
@@ -315,16 +327,12 @@ var Registry = function() {
315
327
  }
316
328
  return pairs;
317
329
  }
318
- var createSortedArray = function createSortedArray() {
319
- return new import_sorted_array.default([], function(c) {
320
- return c.matcher.count;
321
- });
322
- };
323
330
  var Registry = /*#__PURE__*/ function() {
324
- function Registry(initialSet) {
331
+ function Registry(initialSet, logger) {
325
332
  var _this = this;
326
333
  _class_call_check(this, Registry);
327
- this.store = createSortedArray();
334
+ this.store = [];
335
+ this.logger = logger;
328
336
  initialSet === null || initialSet === void 0 ? void 0 : initialSet.forEach(function(param) {
329
337
  var _param = _sliced_to_array(param, 2), match = _param[0], value = _param[1];
330
338
  _this.set(match, value);
@@ -332,22 +340,50 @@ var Registry = function() {
332
340
  }
333
341
  _create_class(Registry, [
334
342
  {
335
- /** Add match -> value mapping to the registry */ key: "set",
343
+ /**
344
+ * Add match -> value mapping to the registry
345
+ *
346
+ * If an entry with the same specificity and matching key already exists, it will be replaced
347
+ * and a debug log will be emitted (if a logger is configured).
348
+ *
349
+ * @param match - The key to match against (can be a primitive or object)
350
+ * @param value - The value to associate with this key
351
+ */ key: "set",
336
352
  value: function set(match, value) {
337
353
  var matcher = (typeof match === "undefined" ? "undefined" : _type_of(match)) === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
338
- this.store.insert({
354
+ var existingIndex = this.store.findIndex(function(entry) {
355
+ return entry.matcher(match) && matcher(entry.key);
356
+ });
357
+ if (existingIndex !== -1) {
358
+ var _this_logger_debug, _this_logger;
359
+ this.store.splice(existingIndex, 1);
360
+ (_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : (_this_logger_debug = _this_logger.debug) === null || _this_logger_debug === void 0 ? void 0 : _this_logger_debug.call(_this_logger, "Registry: Replacing existing entry for key ", match);
361
+ }
362
+ this.store.push({
339
363
  key: match,
340
364
  value: value,
341
365
  matcher: matcher
342
366
  });
367
+ this.store = sort(this.store).desc(function(entry) {
368
+ return entry.matcher.count;
369
+ });
343
370
  }
344
371
  },
345
372
  {
346
- /** Fetch the best match in the registry */ key: "get",
373
+ /**
374
+ * Fetch the best match in the registry
375
+ *
376
+ * Searches for the most specific entry that matches the given query.
377
+ * The registry is sorted by specificity (matcher.count) in descending order,
378
+ * so we iterate forward to find the highest specificity match first.
379
+ *
380
+ * @param query - The query object to match against registered keys
381
+ * @returns The value associated with the best matching key, or undefined if no match found
382
+ */ key: "get",
347
383
  value: function get(query) {
348
384
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
349
385
  try {
350
- for(var _iterator = this.store.array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
386
+ for(var _iterator = this.store[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
351
387
  var entry = _step.value;
352
388
  if (entry.matcher(query)) {
353
389
  return entry.value;
@@ -367,6 +403,7 @@ var Registry = function() {
367
403
  }
368
404
  }
369
405
  }
406
+ return void 0;
370
407
  }
371
408
  },
372
409
  {
@@ -374,7 +411,7 @@ var Registry = function() {
374
411
  value: function forEach(callbackfn) {
375
412
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
376
413
  try {
377
- for(var _iterator = this.store.array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
414
+ for(var _iterator = this.store[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
378
415
  var entry = _step.value;
379
416
  callbackfn(entry);
380
417
  }
@@ -397,13 +434,13 @@ var Registry = function() {
397
434
  {
398
435
  /** Reset the items in the registry */ key: "clear",
399
436
  value: function clear() {
400
- this.store = createSortedArray();
437
+ this.store = [];
401
438
  }
402
439
  },
403
440
  {
404
441
  /** Check if the registry is empty*/ key: "isRegistryEmpty",
405
442
  value: function isRegistryEmpty() {
406
- return this.store.array.length === 0;
443
+ return this.store.length === 0;
407
444
  }
408
445
  }
409
446
  ]);
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2260/execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/dist/index.global.js","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/index.js","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js"],"names":["Registry","dlv_es_default","obj","key","def","p","undef","split","length","createObjectMatcher","partialObj","pairs","traverseObj","matchFunction","searchObj","Array","from","entry","path","value","count","size","createBasicMatcher","seed","matcher","match","__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__commonJS","cb","mod","__require","exports","__export","target","all","name","get","enumerable","__copyProps","to","except","desc","call","__toESM","isNodeMode","__esModule","__toCommonJS","require_sorted_array","module","SortedArray","defclass","array","compare","compareDefault","index","insert","element","high","low","pos","ordering","push","search","remove","splice","comparing","property","a","b","constructor","define","amd","src_exports","import_sorted_array","object","Map","keys","val","nestedPath","set","createSortedArray","c","initialSet","store","forEach","query","callbackfn","clear","isRegistryEmpty"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,WAAW,AAAC;QCDDC,iBDuIb,kJAAkJ;ICvIrI,SAAAA,eAAaC,CAAAA,EAAKC,CAAAA,EAAKC,CAAAA,EAAKC,CAAAA,EAAGC,CAAAA;QAAAA,IAC7CH,IAAMA,EAAII,KAAAA,GAAQJ,EAAII,KAAAA,CAAM,OAAOJ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B,MAAA,CAAO;wBAChBjE,KAAKsB;wBACLN,OAAAA;wBACAK,SAAAA;oBACF;gBACF;;;gBAAA,yCAAA,GAGAyB,KAAAA;uBAAAA,SAAAA,IAAIiD,KAAA;wBACF,kCAAA,2BAAA;;wBAAA,QAAA,YAAoB,IAAA,CAAKF,KAAA,CAAMhC,KAAA,qBAA/B,SAAA,6BAAA,QAAA,yBAAA,iCAAsC;4BAAtC,IAAW/C,QAAX;4BACE,IAAIA,MAAMO,OAAA,CAAQ0E,QAAQ;gCACxB,OAAOjF,MAAME,KAAA;4BACf;wBACF;;wBAJA;wBAAA;;;iCAAA,6BAAA;gCAAA;;;gCAAA;sCAAA;;;;gBAKF;;;gBAAA,2CAAA,GAGA8E,KAAAA;uBAAAA,SAAAA,QAAQE,UAAA;wBACN,kCAAA,2BAAA;;wBAAA,QAAA,YAAoB,IAAA,CAAKH,KAAA,CAAMhC,KAAA,qBAA/B,SAAA,6BAAA,QAAA,yBAAA,iCAAsC;4BAAtC,IAAW/C,QAAX;4BACEkF,WAAWlF;wBACb;;wBAFA;wBAAA;;;iCAAA,6BAAA;gCAAA;;;gCAAA;sCAAA;;;;gBAGF;;;gBAAA,oCAAA,GAGAmF,KAAAA;uBAAAA,SAAAA;oBACE,IAAA,CAAKJ,KAAA,GAAQH;gBACf;;;gBAAA,kCAAA,GAGAQ,KAAAA;uBAAAA,SAAAA;oBACE,OAAO,IAAA,CAAKL,KAAA,CAAMhC,KAAA,CAAMxD,MAAA,KAAW;gBACrC;;;;;IHuIA,OAAOmD,aAAa0B;AACtB","sourcesContent":["\"use strict\";\nvar Registry = (() => {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __commonJS = (cb, mod) => function __require() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n };\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n ));\n var __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js\n var require_sorted_array = __commonJS({\n \"../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/sorted-array@2.0.4/node_modules/sorted-array/sorted-array.js\"(exports, module) {\n \"use strict\";\n var SortedArray2 = function() {\n var SortedArray3 = defclass({\n constructor: function(array, compare) {\n this.array = [];\n this.compare = compare || compareDefault;\n var length = array.length, index = 0;\n while (index < length)\n this.insert(array[index++]);\n },\n insert: function(element) {\n var array = this.array, compare = this.compare, high = array.length - 1, low = 0, pos = -1, index, ordering;\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n if (ordering < 0)\n low = index + 1;\n else if (ordering > 0)\n high = index - 1;\n else {\n pos = index;\n break;\n }\n ;\n }\n if (pos === -1) {\n pos = high;\n }\n pos++;\n high = array.length - 1;\n while (pos < high && compare(element, array[pos]) === 0) {\n pos++;\n }\n index = array.length;\n array.push(element);\n while (index > pos) {\n array[index] = array[--index];\n }\n array[pos] = element;\n return this;\n },\n search: function(element) {\n var array = this.array, compare = this.compare, high = array.length - 1, low = 0, index, ordering;\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n if (ordering < 0)\n low = index + 1;\n else if (ordering > 0)\n high = index - 1;\n else\n return index;\n }\n return -1;\n },\n remove: function(element) {\n var index = this.search(element);\n if (index >= 0)\n this.array.splice(index, 1);\n return this;\n }\n });\n SortedArray3.comparing = function(property, array) {\n return new SortedArray3(array, function(a, b) {\n return compareDefault(a[property], b[property]);\n });\n };\n return SortedArray3;\n function defclass(prototype) {\n var constructor = prototype.constructor;\n constructor.prototype = prototype;\n return constructor;\n }\n function compareDefault(a, b) {\n if (a < b)\n return -1;\n else if (a > b)\n return 1;\n else\n return 0;\n }\n }();\n if (typeof module === \"object\")\n module.exports = SortedArray2;\n if (typeof define === \"function\" && define.amd)\n define(function() {\n return SortedArray2;\n });\n }\n });\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts\n var src_exports = {};\n __export(src_exports, {\n Registry: () => Registry,\n createObjectMatcher: () => createObjectMatcher\n });\n var import_sorted_array = __toESM(require_sorted_array());\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js\n function dlv_es_default(t, e, l, n, r) {\n for (e = e.split ? e.split(\".\") : e, n = 0; n < e.length; n++)\n t = t ? t[e[n]] : r;\n return t === r ? l : t;\n }\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts\n function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {\n for (const key of Object.keys(object)) {\n const val = object[key];\n const nestedPath = [...path, key];\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n return pairs;\n }\n function createObjectMatcher(partialObj) {\n const pairs = traverseObj(partialObj);\n const matchFunction = (searchObj) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n if (dlv_es_default(searchObj, path) !== value) {\n return false;\n }\n }\n return true;\n };\n matchFunction.count = pairs.size;\n return matchFunction;\n }\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts\n function createBasicMatcher(seed) {\n const matcher = (match) => seed === match;\n matcher.count = 1;\n return matcher;\n }\n var createSortedArray = () => new import_sorted_array.default([], (c) => c.matcher.count);\n var Registry = class {\n constructor(initialSet) {\n this.store = createSortedArray();\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n /** Add match -> value mapping to the registry */\n set(match, value) {\n const matcher = typeof match === \"object\" ? createObjectMatcher(match) : createBasicMatcher(match);\n this.store.insert({\n key: match,\n value,\n matcher\n });\n }\n /** Fetch the best match in the registry */\n get(query) {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n /** Loop over all entries and run callback */\n forEach(callbackfn) {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray();\n }\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n };\n return __toCommonJS(src_exports);\n})();\n","export default function dlv(obj, key, def, p, undef) {\n\tkey = key.split ? key.split('.') : key;\n\tfor (p = 0; p < key.length; p++) {\n\t\tobj = obj ? obj[key[p]] : undef;\n\t}\n\treturn obj === undef ? def : obj;\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n","import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/** create an empty sorted array using the matcher count */\nconst createSortedArray = <V>() =>\n new SortedArray<RegistryIndex<V>>([], (c) => c.matcher.count);\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store = createSortedArray<V>();\n\n constructor(initialSet?: Array<[any, V]>) {\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /** Add match -> value mapping to the registry */\n set(match: any, value: V) {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n this.store.insert({\n key: match,\n value,\n matcher,\n });\n }\n\n /** Fetch the best match in the registry */\n get(query: any): V | undefined {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray<V>();\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n}\n","var SortedArray = (function () {\n var SortedArray = defclass({\n\n constructor: function (array, compare) {\n this.array = [];\n this.compare = compare || compareDefault;\n var length = array.length,\n index = 0;\n while (index < length) this.insert(array[index++]);\n },\n insert: function (element) {\n var array = this.array,\n compare = this.compare,\n high = array.length-1,\n low = 0,\n pos = -1,\n index,\n ordering;\n\n // The array is sorted. You must find the position of new element in O(log(n)), not O(n).\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element); \n if (ordering < 0) low = index + 1;\n else if (ordering > 0) high = index - 1;\n else {\n pos = index;\n break;\n };\n }\n\n if (pos === -1) {\n // if element was not found, high < low.\n pos = high;\n }\n // This assures that equal elements inserted after will be in a higher position in array.\n // They can be equal for comparison purposes, but different objects with different data.\n // Respecting the chronological order can be important for many applications.\n pos++;\n high = array.length-1;\n while ((pos < high) && (compare(element, array[pos]) === 0)){\n pos++;\n }\n index = array.length;\n // Just to increase array size.\n array.push(element); \n // Much faster. No need to elements swap.\n while (index > pos) {\n array[index] = array[--index];\n }\n // Set the new element on its correct position.\n array[pos] = element;\n\n return this;\n },\n search: function (element) {\n var array = this.array,\n compare = this.compare,\n high = array.length-1,\n low = 0,\n // In most languages, inner variable declaration makes the code slower.\n index,\n ordering;\n\n while (high >= low) {\n index = (high + low) / 2 >>> 0;\n ordering = compare(array[index], element);\n\n if (ordering < 0) low = index + 1;\n else if (ordering > 0) high = index - 1;\n else return index;\n }\n\n return -1;\n },\n remove: function (element) {\n var index = this.search(element);\n if (index >= 0) this.array.splice(index, 1);\n return this;\n }\n });\n\n SortedArray.comparing = function (property, array) {\n return new SortedArray(array, function (a, b) {\n // This should be faster than calling functions.\n // Besides, this way it is not needed to create useless function to return property value.\n return compareDefault(a[property], b[property]);\n });\n };\n\n return SortedArray;\n\n function defclass(prototype) {\n var constructor = prototype.constructor;\n constructor.prototype = prototype;\n return constructor;\n }\n\n function compareDefault(a, b) {\n // Equality has a very low chance to happen. It should be the last option.\n if (a < b)\n return -1;\n else if (a > b)\n return 1;\n else\n return 0;\n }\n}());\n\nif (typeof module === \"object\") module.exports = SortedArray;\nif (typeof define === \"function\" && define.amd)\n define(function () { return SortedArray; });\n"]}
1
+ {"version":3,"sources":["/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2239/execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/dist/index.global.js","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/fast-sort@3.4.1/node_modules/fast-sort/dist/sort.mjs","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/index.js","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts"],"names":["Registry","createNewSortInstance","opts","comparer","castComparer","arrayToSort","ctx","Array","isArray","inPlaceSorting","slice","asc","sortBy","sortArray","desc","by","dlv_es_default","obj","key","def","p","undef","split","length","createObjectMatcher","partialObj","pairs","traverseObj","matchFunction","searchObj","from","entry","path","value","count","size","createBasicMatcher","seed","matcher","match","__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","except","call","__toCommonJS","mod","src_exports","a","b","order","throwInvalidConfigErrorIfTrue","condition","context","Error","unpackObjectSorter","sortByObj","_a","multiPropertySorterProvider","defaultComparer","multiPropertySorter","sortByArr","depth","valA","valB","objectSorterConfig","equality","getSortStrategy","includes","multiPropSorter_1","sort","inPlaceSort","object","Map","keys","val","nestedPath","set","initialSet","logger","store","forEach","existingIndex","findIndex","splice","debug","push","query","callbackfn","clear","isRegistryEmpty"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,WAAW,AAAC;QC2EPC,wBAAT,SAASA,sBAAsBC,IAAA;QAC3B,IAAIC,WAAWC,aAAaF,KAAKC,QAAQ;QACzC,OAAO,SAAUE,WAAA;YACb,IAAIC,MAAMC,MAAMC,OAAA,CAAQH,gBAAgB,CAACH,KAAKO,cAAA,GACxCJ,YAAYK,KAAA,KACZL;YACN,OAAO;gBACHM,KAAK,SAALA,IAAeC,MAAA;oBACX,OAAOC,UAAU,GAAGP,KAAKM,QAAQT;gBACrC;gBACAW,MAAM,SAANA,KAAgBF,MAAA;oBACZ,OAAOC,UAAU,CAAA,GAAIP,KAAKM,QAAQT;gBACtC;gBACAY,IAAI,SAAJA,GAAcH,MAAA;oBACV,OAAOC,UAAU,GAAGP,KAAKM,QAAQT;gBACrC;YACJ;QACJ;IACJ;QC9Fea,iBF8Ib,kJAAkJ;IE9IrI,SAAAA,eAAaC,CAAAA,EAAKC,CAAAA,EAAKC,CAAAA,EAAKC,CAAAA,EAAGC,CAAAA;QAAAA,IAC7CH,IAAMA,EAAII,KAAAA,GAAQJ,EAAII,KAAAA,CAAM,OAAOJ,GAC9BE,IAAI,GAAGA,IAAIF,EAAIK,MAAAA,EAAQH,IAC3BH,IAAMA,IAAMA,CAAAA,CAAIC,CAAAA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AKT,KAAA,GAAQ,EAAC;gBAChB;;;gBAAA,kCAAA,GAGAU,KAAAA;uBAAAA,SAAAA;oBACE,OAAO,IAAA,CAAKV,KAAA,CAAMxE,MAAA,KAAW;gBAC/B;;;;;IJqIA,OAAOqC,aAAaE;AACtB","sourcesContent":["\"use strict\";\nvar Registry = (() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts\n var src_exports = {};\n __export(src_exports, {\n Registry: () => Registry,\n createObjectMatcher: () => createObjectMatcher\n });\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/fast-sort@3.4.1/node_modules/fast-sort/dist/sort.mjs\n var castComparer = function(comparer) {\n return function(a, b, order) {\n return comparer(a, b, order) * order;\n };\n };\n var throwInvalidConfigErrorIfTrue = function(condition, context) {\n if (condition)\n throw Error(\"Invalid sort config: \" + context);\n };\n var unpackObjectSorter = function(sortByObj) {\n var _a = sortByObj || {}, asc = _a.asc, desc = _a.desc;\n var order = asc ? 1 : -1;\n var sortBy = asc || desc;\n throwInvalidConfigErrorIfTrue(!sortBy, \"Expected `asc` or `desc` property\");\n throwInvalidConfigErrorIfTrue(asc && desc, \"Ambiguous object with `asc` and `desc` config properties\");\n var comparer = sortByObj.comparer && castComparer(sortByObj.comparer);\n return { order, sortBy, comparer };\n };\n var multiPropertySorterProvider = function(defaultComparer2) {\n return function multiPropertySorter(sortBy, sortByArr, depth, order, comparer, a, b) {\n var valA;\n var valB;\n if (typeof sortBy === \"string\") {\n valA = a[sortBy];\n valB = b[sortBy];\n } else if (typeof sortBy === \"function\") {\n valA = sortBy(a);\n valB = sortBy(b);\n } else {\n var objectSorterConfig = unpackObjectSorter(sortBy);\n return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer2, a, b);\n }\n var equality = comparer(valA, valB, order);\n if ((equality === 0 || valA == null && valB == null) && sortByArr.length > depth) {\n return multiPropertySorter(sortByArr[depth], sortByArr, depth + 1, order, comparer, a, b);\n }\n return equality;\n };\n };\n function getSortStrategy(sortBy, comparer, order) {\n if (sortBy === void 0 || sortBy === true) {\n return function(a, b) {\n return comparer(a, b, order);\n };\n }\n if (typeof sortBy === \"string\") {\n throwInvalidConfigErrorIfTrue(sortBy.includes(\".\"), \"String syntax not allowed for nested properties.\");\n return function(a, b) {\n return comparer(a[sortBy], b[sortBy], order);\n };\n }\n if (typeof sortBy === \"function\") {\n return function(a, b) {\n return comparer(sortBy(a), sortBy(b), order);\n };\n }\n if (Array.isArray(sortBy)) {\n var multiPropSorter_1 = multiPropertySorterProvider(comparer);\n return function(a, b) {\n return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b);\n };\n }\n var objectSorterConfig = unpackObjectSorter(sortBy);\n return getSortStrategy(objectSorterConfig.sortBy, objectSorterConfig.comparer || comparer, objectSorterConfig.order);\n }\n var sortArray = function(order, ctx, sortBy, comparer) {\n var _a;\n if (!Array.isArray(ctx)) {\n return ctx;\n }\n if (Array.isArray(sortBy) && sortBy.length < 2) {\n _a = sortBy, sortBy = _a[0];\n }\n return ctx.sort(getSortStrategy(sortBy, comparer, order));\n };\n function createNewSortInstance(opts) {\n var comparer = castComparer(opts.comparer);\n return function(arrayToSort) {\n var ctx = Array.isArray(arrayToSort) && !opts.inPlaceSorting ? arrayToSort.slice() : arrayToSort;\n return {\n asc: function(sortBy) {\n return sortArray(1, ctx, sortBy, comparer);\n },\n desc: function(sortBy) {\n return sortArray(-1, ctx, sortBy, comparer);\n },\n by: function(sortBy) {\n return sortArray(1, ctx, sortBy, comparer);\n }\n };\n };\n }\n var defaultComparer = function(a, b, order) {\n if (a == null)\n return order;\n if (b == null)\n return -order;\n if (typeof a !== typeof b) {\n return typeof a < typeof b ? -1 : 1;\n }\n if (a < b)\n return -1;\n if (a > b)\n return 1;\n return 0;\n };\n var sort = createNewSortInstance({\n comparer: defaultComparer\n });\n var inPlaceSort = createNewSortInstance({\n comparer: defaultComparer,\n inPlaceSorting: true\n });\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js\n function dlv_es_default(t, e, l, n, r) {\n for (e = e.split ? e.split(\".\") : e, n = 0; n < e.length; n++)\n t = t ? t[e[n]] : r;\n return t === r ? l : t;\n }\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts\n function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {\n for (const key of Object.keys(object)) {\n const val = object[key];\n const nestedPath = [...path, key];\n if (typeof val === \"object\" && val !== null) {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n return pairs;\n }\n function createObjectMatcher(partialObj) {\n const pairs = traverseObj(partialObj);\n const matchFunction = (searchObj) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n if (dlv_es_default(searchObj, path) !== value) {\n return false;\n }\n }\n return true;\n };\n matchFunction.count = pairs.size;\n return matchFunction;\n }\n\n // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts\n function createBasicMatcher(seed) {\n const matcher = (match) => seed === match;\n matcher.count = 1;\n return matcher;\n }\n var Registry = class {\n /**\n * Creates a new Registry instance\n *\n * @param initialSet - Optional array of [key, value] tuples to populate the registry\n * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)\n */\n constructor(initialSet, logger) {\n this.store = [];\n this.logger = logger;\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n /**\n * Add match -> value mapping to the registry\n *\n * If an entry with the same specificity and matching key already exists, it will be replaced\n * and a debug log will be emitted (if a logger is configured).\n *\n * @param match - The key to match against (can be a primitive or object)\n * @param value - The value to associate with this key\n */\n set(match, value) {\n const matcher = typeof match === \"object\" ? createObjectMatcher(match) : createBasicMatcher(match);\n const existingIndex = this.store.findIndex(\n (entry) => entry.matcher(match) && matcher(entry.key)\n );\n if (existingIndex !== -1) {\n this.store.splice(existingIndex, 1);\n this.logger?.debug?.(\n \"Registry: Replacing existing entry for key \",\n match\n );\n }\n this.store.push({\n key: match,\n value,\n matcher\n });\n this.store = sort(this.store).desc((entry) => entry.matcher.count);\n }\n /**\n * Fetch the best match in the registry\n *\n * Searches for the most specific entry that matches the given query.\n * The registry is sorted by specificity (matcher.count) in descending order,\n * so we iterate forward to find the highest specificity match first.\n *\n * @param query - The query object to match against registered keys\n * @returns The value associated with the best matching key, or undefined if no match found\n */\n get(query) {\n for (const entry of this.store) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n return void 0;\n }\n /** Loop over all entries and run callback */\n forEach(callbackfn) {\n for (const entry of this.store) {\n callbackfn(entry);\n }\n }\n /** Reset the items in the registry */\n clear() {\n this.store = [];\n }\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.length === 0;\n }\n };\n return __toCommonJS(src_exports);\n})();\n","// >>> INTERFACES <<<\r\n// >>> HELPERS <<<\r\nvar castComparer = function (comparer) { return function (a, b, order) { return comparer(a, b, order) * order; }; };\r\nvar throwInvalidConfigErrorIfTrue = function (condition, context) {\r\n if (condition)\r\n throw Error(\"Invalid sort config: \" + context);\r\n};\r\nvar unpackObjectSorter = function (sortByObj) {\r\n var _a = sortByObj || {}, asc = _a.asc, desc = _a.desc;\r\n var order = asc ? 1 : -1;\r\n var sortBy = (asc || desc);\r\n // Validate object config\r\n throwInvalidConfigErrorIfTrue(!sortBy, 'Expected `asc` or `desc` property');\r\n throwInvalidConfigErrorIfTrue(asc && desc, 'Ambiguous object with `asc` and `desc` config properties');\r\n var comparer = sortByObj.comparer && castComparer(sortByObj.comparer);\r\n return { order: order, sortBy: sortBy, comparer: comparer };\r\n};\r\n// >>> SORTERS <<<\r\nvar multiPropertySorterProvider = function (defaultComparer) {\r\n return function multiPropertySorter(sortBy, sortByArr, depth, order, comparer, a, b) {\r\n var valA;\r\n var valB;\r\n if (typeof sortBy === 'string') {\r\n valA = a[sortBy];\r\n valB = b[sortBy];\r\n }\r\n else if (typeof sortBy === 'function') {\r\n valA = sortBy(a);\r\n valB = sortBy(b);\r\n }\r\n else {\r\n var objectSorterConfig = unpackObjectSorter(sortBy);\r\n return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer, a, b);\r\n }\r\n var equality = comparer(valA, valB, order);\r\n if ((equality === 0 || (valA == null && valB == null)) &&\r\n sortByArr.length > depth) {\r\n return multiPropertySorter(sortByArr[depth], sortByArr, depth + 1, order, comparer, a, b);\r\n }\r\n return equality;\r\n };\r\n};\r\nfunction getSortStrategy(sortBy, comparer, order) {\r\n // Flat array sorter\r\n if (sortBy === undefined || sortBy === true) {\r\n return function (a, b) { return comparer(a, b, order); };\r\n }\r\n // Sort list of objects by single object key\r\n if (typeof sortBy === 'string') {\r\n throwInvalidConfigErrorIfTrue(sortBy.includes('.'), 'String syntax not allowed for nested properties.');\r\n return function (a, b) { return comparer(a[sortBy], b[sortBy], order); };\r\n }\r\n // Sort list of objects by single function sorter\r\n if (typeof sortBy === 'function') {\r\n return function (a, b) { return comparer(sortBy(a), sortBy(b), order); };\r\n }\r\n // Sort by multiple properties\r\n if (Array.isArray(sortBy)) {\r\n var multiPropSorter_1 = multiPropertySorterProvider(comparer);\r\n return function (a, b) { return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b); };\r\n }\r\n // Unpack object config to get actual sorter strategy\r\n var objectSorterConfig = unpackObjectSorter(sortBy);\r\n return getSortStrategy(objectSorterConfig.sortBy, objectSorterConfig.comparer || comparer, objectSorterConfig.order);\r\n}\r\nvar sortArray = function (order, ctx, sortBy, comparer) {\r\n var _a;\r\n if (!Array.isArray(ctx)) {\r\n return ctx;\r\n }\r\n // Unwrap sortBy if array with only 1 value to get faster sort strategy\r\n if (Array.isArray(sortBy) && sortBy.length < 2) {\r\n _a = sortBy, sortBy = _a[0];\r\n }\r\n return ctx.sort(getSortStrategy(sortBy, comparer, order));\r\n};\r\nfunction createNewSortInstance(opts) {\r\n var comparer = castComparer(opts.comparer);\r\n return function (arrayToSort) {\r\n var ctx = Array.isArray(arrayToSort) && !opts.inPlaceSorting\r\n ? arrayToSort.slice()\r\n : arrayToSort;\r\n return {\r\n asc: function (sortBy) {\r\n return sortArray(1, ctx, sortBy, comparer);\r\n },\r\n desc: function (sortBy) {\r\n return sortArray(-1, ctx, sortBy, comparer);\r\n },\r\n by: function (sortBy) {\r\n return sortArray(1, ctx, sortBy, comparer);\r\n },\r\n };\r\n };\r\n}\r\nvar defaultComparer = function (a, b, order) {\r\n if (a == null)\r\n return order;\r\n if (b == null)\r\n return -order;\r\n if (typeof a !== typeof b) {\r\n return typeof a < typeof b ? -1 : 1;\r\n }\r\n if (a < b)\r\n return -1;\r\n if (a > b)\r\n return 1;\r\n return 0;\r\n};\r\nvar sort = createNewSortInstance({\r\n comparer: defaultComparer,\r\n});\r\nvar inPlaceSort = createNewSortInstance({\r\n comparer: defaultComparer,\r\n inPlaceSorting: true,\r\n});\n\nexport { createNewSortInstance, defaultComparer, inPlaceSort, sort };\n","export default function dlv(obj, key, def, p, undef) {\n\tkey = key.split ? key.split('.') : key;\n\tfor (p = 0; p < key.length; p++) {\n\t\tobj = obj ? obj[key[p]] : undef;\n\t}\n\treturn obj === undef ? def : obj;\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n /* Explicitly avoid traversing null values.\n JavaScript's typeof null === \"object\" would otherwise cause the function to traverse null as an object\n and throw an error. \n \n Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n */\n if (typeof val === \"object\" && val !== null) {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n","import { sort } from \"fast-sort\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** Minimal logger interface for registry operations */\ninterface Logger {\n debug?: (...args: Array<any>) => void;\n}\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store: Array<RegistryIndex<V>> = [];\n private logger?: Logger;\n\n /**\n * Creates a new Registry instance\n *\n * @param initialSet - Optional array of [key, value] tuples to populate the registry\n * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)\n */\n constructor(initialSet?: Array<[any, V]>, logger?: Logger) {\n this.logger = logger;\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /**\n * Add match -> value mapping to the registry\n *\n * If an entry with the same specificity and matching key already exists, it will be replaced\n * and a debug log will be emitted (if a logger is configured).\n *\n * @param match - The key to match against (can be a primitive or object)\n * @param value - The value to associate with this key\n */\n set(match: any, value: V): void {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n // Find and remove any existing entry that matches this key\n // Use matcher to check for matching keys (handles deep equality)\n const existingIndex = this.store.findIndex(\n (entry) => entry.matcher(match) && matcher(entry.key),\n );\n if (existingIndex !== -1) {\n this.store.splice(existingIndex, 1);\n this.logger?.debug?.(\n \"Registry: Replacing existing entry for key \",\n match,\n );\n }\n\n this.store.push({\n key: match,\n value,\n matcher,\n });\n\n // Sort in descending order by matcher.count (highest specificity first)\n this.store = sort(this.store).desc((entry) => entry.matcher.count);\n }\n\n /**\n * Fetch the best match in the registry\n *\n * Searches for the most specific entry that matches the given query.\n * The registry is sorted by specificity (matcher.count) in descending order,\n * so we iterate forward to find the highest specificity match first.\n *\n * @param query - The query object to match against registered keys\n * @returns The value associated with the best matching key, or undefined if no match found\n */\n get(query: any): V | undefined {\n // Store is sorted by matcher.count (descending), so iterate forward\n for (const entry of this.store) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n return undefined;\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear(): void {\n this.store = [];\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty(): boolean {\n return this.store.length === 0;\n }\n}\n"]}
@@ -34,7 +34,7 @@ __export(src_exports, {
34
34
  createObjectMatcher: () => createObjectMatcher
35
35
  });
36
36
  module.exports = __toCommonJS(src_exports);
37
- var import_sorted_array = __toESM(require("sorted-array"));
37
+ var import_fast_sort = require("fast-sort");
38
38
 
39
39
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts
40
40
  var import_dlv = __toESM(require("dlv"));
@@ -42,7 +42,7 @@ function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {
42
42
  for (const key of Object.keys(object)) {
43
43
  const val = object[key];
44
44
  const nestedPath = [...path, key];
45
- if (typeof val === "object") {
45
+ if (typeof val === "object" && val !== null) {
46
46
  traverseObj(val, nestedPath, pairs);
47
47
  } else {
48
48
  pairs.set(nestedPath, val);
@@ -71,44 +71,79 @@ function createBasicMatcher(seed) {
71
71
  matcher.count = 1;
72
72
  return matcher;
73
73
  }
74
- var createSortedArray = () => new import_sorted_array.default([], (c) => c.matcher.count);
75
74
  var Registry = class {
76
- constructor(initialSet) {
77
- this.store = createSortedArray();
75
+ /**
76
+ * Creates a new Registry instance
77
+ *
78
+ * @param initialSet - Optional array of [key, value] tuples to populate the registry
79
+ * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)
80
+ */
81
+ constructor(initialSet, logger) {
82
+ this.store = [];
83
+ this.logger = logger;
78
84
  initialSet?.forEach(([match, value]) => {
79
85
  this.set(match, value);
80
86
  });
81
87
  }
82
- /** Add match -> value mapping to the registry */
88
+ /**
89
+ * Add match -> value mapping to the registry
90
+ *
91
+ * If an entry with the same specificity and matching key already exists, it will be replaced
92
+ * and a debug log will be emitted (if a logger is configured).
93
+ *
94
+ * @param match - The key to match against (can be a primitive or object)
95
+ * @param value - The value to associate with this key
96
+ */
83
97
  set(match, value) {
84
98
  const matcher = typeof match === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
85
- this.store.insert({
99
+ const existingIndex = this.store.findIndex(
100
+ (entry) => entry.matcher(match) && matcher(entry.key)
101
+ );
102
+ if (existingIndex !== -1) {
103
+ this.store.splice(existingIndex, 1);
104
+ this.logger?.debug?.(
105
+ "Registry: Replacing existing entry for key ",
106
+ match
107
+ );
108
+ }
109
+ this.store.push({
86
110
  key: match,
87
111
  value,
88
112
  matcher
89
113
  });
114
+ this.store = (0, import_fast_sort.sort)(this.store).desc((entry) => entry.matcher.count);
90
115
  }
91
- /** Fetch the best match in the registry */
116
+ /**
117
+ * Fetch the best match in the registry
118
+ *
119
+ * Searches for the most specific entry that matches the given query.
120
+ * The registry is sorted by specificity (matcher.count) in descending order,
121
+ * so we iterate forward to find the highest specificity match first.
122
+ *
123
+ * @param query - The query object to match against registered keys
124
+ * @returns The value associated with the best matching key, or undefined if no match found
125
+ */
92
126
  get(query) {
93
- for (const entry of this.store.array) {
127
+ for (const entry of this.store) {
94
128
  if (entry.matcher(query)) {
95
129
  return entry.value;
96
130
  }
97
131
  }
132
+ return void 0;
98
133
  }
99
134
  /** Loop over all entries and run callback */
100
135
  forEach(callbackfn) {
101
- for (const entry of this.store.array) {
136
+ for (const entry of this.store) {
102
137
  callbackfn(entry);
103
138
  }
104
139
  }
105
140
  /** Reset the items in the registry */
106
141
  clear() {
107
- this.store = createSortedArray();
142
+ this.store = [];
108
143
  }
109
144
  /** Check if the registry is empty*/
110
145
  isRegistryEmpty() {
111
- return this.store.array.length === 0;
146
+ return this.store.length === 0;
112
147
  }
113
148
  };
114
149
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts"],"sourcesContent":["import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/** create an empty sorted array using the matcher count */\nconst createSortedArray = <V>() =>\n new SortedArray<RegistryIndex<V>>([], (c) => c.matcher.count);\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store = createSortedArray<V>();\n\n constructor(initialSet?: Array<[any, V]>) {\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /** Add match -> value mapping to the registry */\n set(match: any, value: V) {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n this.store.insert({\n key: match,\n value,\n matcher,\n });\n }\n\n /** Fetch the best match in the registry */\n get(query: any): V | undefined {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray<V>();\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAwB;;;ACAxB,iBAAgB;AAShB,SAAS,YACP,QACA,OAAiB,CAAC,GAClB,QAA4B,oBAAI,IAAI,GAChB;AACpB,aAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AACrC,UAAM,MAAW,OAAO,GAAG;AAC3B,UAAM,aAAa,CAAC,GAAG,MAAM,GAAG;AAEhC,QAAI,OAAO,QAAQ,UAAU;AAC3B,kBAAY,KAAK,YAAY,KAAK;AAAA,IACpC,OAAO;AACL,YAAM,IAAI,YAAY,GAAG;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AACT;AAOO,SAAS,oBAAoB,YAA6B;AAE/D,QAAM,QAAQ,YAAY,UAAU;AAGpC,QAAM,gBAAgB,CAAC,cAAsB;AAC3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["dlv","SortedArray"]}
1
+ {"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts"],"sourcesContent":["import { sort } from \"fast-sort\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** Minimal logger interface for registry operations */\ninterface Logger {\n debug?: (...args: Array<any>) => void;\n}\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store: Array<RegistryIndex<V>> = [];\n private logger?: Logger;\n\n /**\n * Creates a new Registry instance\n *\n * @param initialSet - Optional array of [key, value] tuples to populate the registry\n * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)\n */\n constructor(initialSet?: Array<[any, V]>, logger?: Logger) {\n this.logger = logger;\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /**\n * Add match -> value mapping to the registry\n *\n * If an entry with the same specificity and matching key already exists, it will be replaced\n * and a debug log will be emitted (if a logger is configured).\n *\n * @param match - The key to match against (can be a primitive or object)\n * @param value - The value to associate with this key\n */\n set(match: any, value: V): void {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n // Find and remove any existing entry that matches this key\n // Use matcher to check for matching keys (handles deep equality)\n const existingIndex = this.store.findIndex(\n (entry) => entry.matcher(match) && matcher(entry.key),\n );\n if (existingIndex !== -1) {\n this.store.splice(existingIndex, 1);\n this.logger?.debug?.(\n \"Registry: Replacing existing entry for key \",\n match,\n );\n }\n\n this.store.push({\n key: match,\n value,\n matcher,\n });\n\n // Sort in descending order by matcher.count (highest specificity first)\n this.store = sort(this.store).desc((entry) => entry.matcher.count);\n }\n\n /**\n * Fetch the best match in the registry\n *\n * Searches for the most specific entry that matches the given query.\n * The registry is sorted by specificity (matcher.count) in descending order,\n * so we iterate forward to find the highest specificity match first.\n *\n * @param query - The query object to match against registered keys\n * @returns The value associated with the best matching key, or undefined if no match found\n */\n get(query: any): V | undefined {\n // Store is sorted by matcher.count (descending), so iterate forward\n for (const entry of this.store) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n return undefined;\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear(): void {\n this.store = [];\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty(): boolean {\n return this.store.length === 0;\n }\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n /* Explicitly avoid traversing null values.\n JavaScript's typeof null === \"object\" would otherwise cause the function to traverse null as an object\n and throw an error. \n \n Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n */\n if (typeof val === \"object\" && val !== null) {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAqB;;;ACArB,iBAAgB;AAShB,SAAS,YACP,QACA,OAAiB,CAAC,GAClB,QAA4B,oBAAI,IAAI,GAChB;AACpB,aAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AACrC,UAAM,MAAW,OAAO,GAAG;AAC3B,UAAM,aAAa,CAAC,GAAG,MAAM,GAAG;AAQhC,QAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAC3C,kBAAY,KAAK,YAAY,KAAK;AAAA,IACpC,OAAO;AACL,YAAM,IAAI,YAAY,GAAG;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AACT;AAOO,SAAS,oBAAoB,YAA6B;AAE/D,QAAM,QAAQ,YAAY,UAAU;AAGpC,QAAM,gBAAgB,CAAC,cAAsB;AAC3C,eAAW,SAAS,MAAM,KAAK,KAAK,GAAG;AACrC,YAAM,CAAC,MAAM,KAAK,IAAI;AAEtB,cAAI,WAAAA,SAAI,WAAW,IAAI,MAAM,OAAO;AAClC,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAGA,gBAAc,QAAQ,MAAM;AAE5B,SAAO;AACT;;;ADhDA,SAAS,mBAAmB,MAAoB;AAE9C,QAAM,UAAU,CAAC,UAAe,SAAS;AACzC,UAAQ,QAAQ;AAEhB,SAAO;AACT;AAiBO,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AAO,KAAK,MAAM,WAAW;AAAA,EAC/B;AACF;","names":["dlv"]}
@@ -1,5 +1,5 @@
1
1
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts
2
- import SortedArray from "sorted-array";
2
+ import { sort } from "fast-sort";
3
3
 
4
4
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts
5
5
  import dlv from "dlv";
@@ -7,7 +7,7 @@ function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {
7
7
  for (const key of Object.keys(object)) {
8
8
  const val = object[key];
9
9
  const nestedPath = [...path, key];
10
- if (typeof val === "object") {
10
+ if (typeof val === "object" && val !== null) {
11
11
  traverseObj(val, nestedPath, pairs);
12
12
  } else {
13
13
  pairs.set(nestedPath, val);
@@ -36,44 +36,79 @@ function createBasicMatcher(seed) {
36
36
  matcher.count = 1;
37
37
  return matcher;
38
38
  }
39
- var createSortedArray = () => new SortedArray([], (c) => c.matcher.count);
40
39
  var Registry = class {
41
- constructor(initialSet) {
42
- this.store = createSortedArray();
40
+ /**
41
+ * Creates a new Registry instance
42
+ *
43
+ * @param initialSet - Optional array of [key, value] tuples to populate the registry
44
+ * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)
45
+ */
46
+ constructor(initialSet, logger) {
47
+ this.store = [];
48
+ this.logger = logger;
43
49
  initialSet?.forEach(([match, value]) => {
44
50
  this.set(match, value);
45
51
  });
46
52
  }
47
- /** Add match -> value mapping to the registry */
53
+ /**
54
+ * Add match -> value mapping to the registry
55
+ *
56
+ * If an entry with the same specificity and matching key already exists, it will be replaced
57
+ * and a debug log will be emitted (if a logger is configured).
58
+ *
59
+ * @param match - The key to match against (can be a primitive or object)
60
+ * @param value - The value to associate with this key
61
+ */
48
62
  set(match, value) {
49
63
  const matcher = typeof match === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
50
- this.store.insert({
64
+ const existingIndex = this.store.findIndex(
65
+ (entry) => entry.matcher(match) && matcher(entry.key)
66
+ );
67
+ if (existingIndex !== -1) {
68
+ this.store.splice(existingIndex, 1);
69
+ this.logger?.debug?.(
70
+ "Registry: Replacing existing entry for key ",
71
+ match
72
+ );
73
+ }
74
+ this.store.push({
51
75
  key: match,
52
76
  value,
53
77
  matcher
54
78
  });
79
+ this.store = sort(this.store).desc((entry) => entry.matcher.count);
55
80
  }
56
- /** Fetch the best match in the registry */
81
+ /**
82
+ * Fetch the best match in the registry
83
+ *
84
+ * Searches for the most specific entry that matches the given query.
85
+ * The registry is sorted by specificity (matcher.count) in descending order,
86
+ * so we iterate forward to find the highest specificity match first.
87
+ *
88
+ * @param query - The query object to match against registered keys
89
+ * @returns The value associated with the best matching key, or undefined if no match found
90
+ */
57
91
  get(query) {
58
- for (const entry of this.store.array) {
92
+ for (const entry of this.store) {
59
93
  if (entry.matcher(query)) {
60
94
  return entry.value;
61
95
  }
62
96
  }
97
+ return void 0;
63
98
  }
64
99
  /** Loop over all entries and run callback */
65
100
  forEach(callbackfn) {
66
- for (const entry of this.store.array) {
101
+ for (const entry of this.store) {
67
102
  callbackfn(entry);
68
103
  }
69
104
  }
70
105
  /** Reset the items in the registry */
71
106
  clear() {
72
- this.store = createSortedArray();
107
+ this.store = [];
73
108
  }
74
109
  /** Check if the registry is empty*/
75
110
  isRegistryEmpty() {
76
- return this.store.array.length === 0;
111
+ return this.store.length === 0;
77
112
  }
78
113
  };
79
114
  export {
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts
2
- import SortedArray from "sorted-array";
2
+ import { sort } from "fast-sort";
3
3
 
4
4
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts
5
5
  import dlv from "dlv";
@@ -7,7 +7,7 @@ function traverseObj(object, path = [], pairs = /* @__PURE__ */ new Map()) {
7
7
  for (const key of Object.keys(object)) {
8
8
  const val = object[key];
9
9
  const nestedPath = [...path, key];
10
- if (typeof val === "object") {
10
+ if (typeof val === "object" && val !== null) {
11
11
  traverseObj(val, nestedPath, pairs);
12
12
  } else {
13
13
  pairs.set(nestedPath, val);
@@ -36,44 +36,79 @@ function createBasicMatcher(seed) {
36
36
  matcher.count = 1;
37
37
  return matcher;
38
38
  }
39
- var createSortedArray = () => new SortedArray([], (c) => c.matcher.count);
40
39
  var Registry = class {
41
- constructor(initialSet) {
42
- this.store = createSortedArray();
40
+ /**
41
+ * Creates a new Registry instance
42
+ *
43
+ * @param initialSet - Optional array of [key, value] tuples to populate the registry
44
+ * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)
45
+ */
46
+ constructor(initialSet, logger) {
47
+ this.store = [];
48
+ this.logger = logger;
43
49
  initialSet?.forEach(([match, value]) => {
44
50
  this.set(match, value);
45
51
  });
46
52
  }
47
- /** Add match -> value mapping to the registry */
53
+ /**
54
+ * Add match -> value mapping to the registry
55
+ *
56
+ * If an entry with the same specificity and matching key already exists, it will be replaced
57
+ * and a debug log will be emitted (if a logger is configured).
58
+ *
59
+ * @param match - The key to match against (can be a primitive or object)
60
+ * @param value - The value to associate with this key
61
+ */
48
62
  set(match, value) {
49
63
  const matcher = typeof match === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
50
- this.store.insert({
64
+ const existingIndex = this.store.findIndex(
65
+ (entry) => entry.matcher(match) && matcher(entry.key)
66
+ );
67
+ if (existingIndex !== -1) {
68
+ this.store.splice(existingIndex, 1);
69
+ this.logger?.debug?.(
70
+ "Registry: Replacing existing entry for key ",
71
+ match
72
+ );
73
+ }
74
+ this.store.push({
51
75
  key: match,
52
76
  value,
53
77
  matcher
54
78
  });
79
+ this.store = sort(this.store).desc((entry) => entry.matcher.count);
55
80
  }
56
- /** Fetch the best match in the registry */
81
+ /**
82
+ * Fetch the best match in the registry
83
+ *
84
+ * Searches for the most specific entry that matches the given query.
85
+ * The registry is sorted by specificity (matcher.count) in descending order,
86
+ * so we iterate forward to find the highest specificity match first.
87
+ *
88
+ * @param query - The query object to match against registered keys
89
+ * @returns The value associated with the best matching key, or undefined if no match found
90
+ */
57
91
  get(query) {
58
- for (const entry of this.store.array) {
92
+ for (const entry of this.store) {
59
93
  if (entry.matcher(query)) {
60
94
  return entry.value;
61
95
  }
62
96
  }
97
+ return void 0;
63
98
  }
64
99
  /** Loop over all entries and run callback */
65
100
  forEach(callbackfn) {
66
- for (const entry of this.store.array) {
101
+ for (const entry of this.store) {
67
102
  callbackfn(entry);
68
103
  }
69
104
  }
70
105
  /** Reset the items in the registry */
71
106
  clear() {
72
- this.store = createSortedArray();
107
+ this.store = [];
73
108
  }
74
109
  /** Check if the registry is empty*/
75
110
  isRegistryEmpty() {
76
- return this.store.array.length === 0;
111
+ return this.store.length === 0;
77
112
  }
78
113
  };
79
114
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts"],"sourcesContent":["import SortedArray from \"sorted-array\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/** create an empty sorted array using the matcher count */\nconst createSortedArray = <V>() =>\n new SortedArray<RegistryIndex<V>>([], (c) => c.matcher.count);\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store = createSortedArray<V>();\n\n constructor(initialSet?: Array<[any, V]>) {\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /** Add match -> value mapping to the registry */\n set(match: any, value: V) {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n this.store.insert({\n key: match,\n value,\n matcher,\n });\n }\n\n /** Fetch the best match in the registry */\n get(query: any): V | undefined {\n for (const entry of this.store.array) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store.array) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear() {\n this.store = createSortedArray<V>();\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty() {\n return this.store.array.length === 0;\n }\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n if (typeof val === \"object\") {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n //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zB,mBAAmB,KAAK;AAE9B,SAAK,MAAM,OAAO;AAAA,MAChB,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,IAAI,OAA2B;AAC7B,eAAW,SAAS,KAAK,MAAM,OAAO;AACpC,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,MAAM;AAAA,MACf;AAAA,IACF;AAAA,EACF;AAAA;AAAA,EAGA,QAAQ,YAAqD;AAC3D,eAAW,SAAS,KAAK,MAAM,OAAO;AACpC,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF;AAAA;AAAA,EAGA,QAAQ;AACN,SAAK,QAAQ,kBAAqB;AAAA,EACpC;AAAA;AAAA,EAGA,kBAAkB;AAChB,WAAO,KAAK,MAAM,MAAM,WAAW;AAAA,EACrC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/partial-match-registry/src/deep-partial-matcher.ts"],"sourcesContent":["import { sort } from \"fast-sort\";\nimport type { Matcher } from \"./deep-partial-matcher\";\nimport { createObjectMatcher } from \"./deep-partial-matcher\";\n\nexport { createObjectMatcher } from \"./deep-partial-matcher\";\n\n/** Minimal logger interface for registry operations */\ninterface Logger {\n debug?: (...args: Array<any>) => void;\n}\n\n/** create a matcher function that matches exactly */\nfunction createBasicMatcher(seed: any): Matcher {\n /** a simple matcher function that only matches itself */\n const matcher = (match: any) => seed === match;\n matcher.count = 1;\n\n return matcher;\n}\n\ninterface RegistryIndex<V> {\n /** The original object we wanted to match on */\n key: object;\n\n /** The value to return */\n value: V;\n\n /** The matcher function for this entry */\n matcher: Matcher;\n}\n\n/**\n * A partial match registry is a map that uses an object to \"match\" against keys.\n * More specific matches take precedence over less specific ones.\n */\nexport class Registry<V> {\n private store: Array<RegistryIndex<V>> = [];\n private logger?: Logger;\n\n /**\n * Creates a new Registry instance\n *\n * @param initialSet - Optional array of [key, value] tuples to populate the registry\n * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)\n */\n constructor(initialSet?: Array<[any, V]>, logger?: Logger) {\n this.logger = logger;\n initialSet?.forEach(([match, value]) => {\n this.set(match, value);\n });\n }\n\n /**\n * Add match -> value mapping to the registry\n *\n * If an entry with the same specificity and matching key already exists, it will be replaced\n * and a debug log will be emitted (if a logger is configured).\n *\n * @param match - The key to match against (can be a primitive or object)\n * @param value - The value to associate with this key\n */\n set(match: any, value: V): void {\n const matcher =\n typeof match === \"object\"\n ? createObjectMatcher(match)\n : createBasicMatcher(match);\n\n // Find and remove any existing entry that matches this key\n // Use matcher to check for matching keys (handles deep equality)\n const existingIndex = this.store.findIndex(\n (entry) => entry.matcher(match) && matcher(entry.key),\n );\n if (existingIndex !== -1) {\n this.store.splice(existingIndex, 1);\n this.logger?.debug?.(\n \"Registry: Replacing existing entry for key \",\n match,\n );\n }\n\n this.store.push({\n key: match,\n value,\n matcher,\n });\n\n // Sort in descending order by matcher.count (highest specificity first)\n this.store = sort(this.store).desc((entry) => entry.matcher.count);\n }\n\n /**\n * Fetch the best match in the registry\n *\n * Searches for the most specific entry that matches the given query.\n * The registry is sorted by specificity (matcher.count) in descending order,\n * so we iterate forward to find the highest specificity match first.\n *\n * @param query - The query object to match against registered keys\n * @returns The value associated with the best matching key, or undefined if no match found\n */\n get(query: any): V | undefined {\n // Store is sorted by matcher.count (descending), so iterate forward\n for (const entry of this.store) {\n if (entry.matcher(query)) {\n return entry.value;\n }\n }\n return undefined;\n }\n\n /** Loop over all entries and run callback */\n forEach(callbackfn: (value: RegistryIndex<V>) => void): void {\n for (const entry of this.store) {\n callbackfn(entry);\n }\n }\n\n /** Reset the items in the registry */\n clear(): void {\n this.store = [];\n }\n\n /** Check if the registry is empty*/\n isRegistryEmpty(): boolean {\n return this.store.length === 0;\n }\n}\n","import dlv from \"dlv\";\n\n/** A function that checks overlapping properties against a reference value */\nexport type Matcher = ((searchObj: object) => boolean) & {\n /** The count represents the specificity of this matcher */\n count: number;\n};\n\n/** Traverse an object and collect any key/value pairs including nested keys */\nfunction traverseObj(\n object: Record<any, any>,\n path: string[] = [],\n pairs: Map<string[], any> = new Map(),\n): Map<string[], any> {\n for (const key of Object.keys(object)) {\n const val: any = object[key];\n const nestedPath = [...path, key];\n\n /* Explicitly avoid traversing null values.\n JavaScript's typeof null === \"object\" would otherwise cause the function to traverse null as an object\n and throw an error. \n \n Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n */\n if (typeof val === \"object\" && val !== null) {\n traverseObj(val, nestedPath, pairs);\n } else {\n pairs.set(nestedPath, val);\n }\n }\n\n return pairs;\n}\n\n/**\n * Given a partial object, create a matcher function that checks if another object matches the specified properties\n * @param partialObj The partial object to match against\n * @returns A matcher function that checks if an object matches the partial object\n */\nexport function createObjectMatcher(partialObj: object): Matcher {\n // Convert the partial object into a list of [key, value] pairs;\n const pairs = traverseObj(partialObj);\n\n /** Generate a function to match against all of the properties we care about */\n const matchFunction = (searchObj: object) => {\n for (const entry of Array.from(pairs)) {\n const [path, value] = entry;\n\n if (dlv(searchObj, path) !== value) {\n return false;\n }\n }\n\n return true;\n };\n\n // Keep track of the specificity of the comparator\n matchFunction.count = pairs.size;\n\n return matchFunction;\n}\n"],"mappings":";AAAA,SAAS,YAAY;;;ACArB,OAAO,SAAS;AAShB,SAAS,YACP,QACA,OAAiB,CAAC,GAClB,QAA4B,oBAAI,IAAI,GAChB;AACpB,aAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AACrC,UAAM,MAAW,OAAO,GAAG;AAC3B,UAAM,aAAa,CAAC,GAAG,MAAM,GAAG;AAQhC,QAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAC3C,kBAAY,KAAK,YAAY,KAAK;AAAA,IACpC,OAAO;AACL,YAAM,IAAI,YAAY,GAAG;AAAA,IAC3B;AAAA,EACF;AAEA,SAA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,KAAK;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,IAAI,OAA2B;AAE7B,eAAW,SAAS,KAAK,OAAO;AAC9B,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,MAAM;AAAA,MACf;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,QAAQ,YAAqD;AAC3D,eAAW,SAAS,KAAK,OAAO;AAC9B,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF;AAAA;AAAA,EAGA,QAAc;AACZ,SAAK,QAAQ,CAAC;AAAA,EAChB;AAAA;AAAA,EAGA,kBAA2B;AACzB,WAAO,KAAK,MAAM,WAAW;AAAA,EAC/B;AACF;","names":[]}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "types"
7
7
  ],
8
8
  "name": "@player-ui/partial-match-registry",
9
- "version": "0.15.3",
9
+ "version": "0.15.4--canary.881.37421",
10
10
  "main": "dist/cjs/index.cjs",
11
11
  "module": "dist/index.legacy-esm.js",
12
12
  "types": "types/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@types/dlv": "^1.1.4",
25
25
  "dlv": "^1.1.3",
26
- "sorted-array": "^2.0.4",
26
+ "fast-sort": "^3.4.1",
27
27
  "tslib": "^2.6.2"
28
28
  },
29
29
  "peerDependencies": {}
@@ -7,3 +7,27 @@ test("works on basic objects", () => {
7
7
  expect(matcher({ foo: "bar" })).toBe(true);
8
8
  expect(matcher({ foo: "bar", bar: "baz" })).toBe(true);
9
9
  });
10
+
11
+ test("handles null values correctly", () => {
12
+ // Test matching on null value
13
+ const matcherWithNull = createObjectMatcher({ foo: null });
14
+ expect(matcherWithNull({ foo: null })).toBe(true);
15
+ expect(matcherWithNull({ foo: "bar" })).toBe(false);
16
+ expect(matcherWithNull({})).toBe(false);
17
+
18
+ // Test matching on combination of null and non-null values
19
+ const matcherMixed = createObjectMatcher({ foo: null, bar: "baz" });
20
+ expect(matcherMixed({ foo: null, bar: "baz" })).toBe(true);
21
+ expect(matcherMixed({ foo: null, bar: "other" })).toBe(false);
22
+ expect(matcherMixed({ foo: "something", bar: "baz" })).toBe(false);
23
+ });
24
+
25
+ test("handles undefined values correctly", () => {
26
+ // Test matching on undefined value
27
+ // Note: dlv treats missing properties the same as undefined, so { foo: undefined } matches {}
28
+ const matcherWithUndefined = createObjectMatcher({ foo: undefined });
29
+ expect(matcherWithUndefined({ foo: undefined })).toBe(true);
30
+ expect(matcherWithUndefined({})).toBe(true); // Missing property is treated as undefined
31
+ expect(matcherWithUndefined({ foo: "bar" })).toBe(false);
32
+ expect(matcherWithUndefined({ foo: null })).toBe(false);
33
+ });
@@ -1,4 +1,4 @@
1
- import { test, expect, beforeEach } from "vitest";
1
+ import { test, expect, beforeEach, vi } from "vitest";
2
2
 
3
3
  import { Registry } from "..";
4
4
 
@@ -27,7 +27,7 @@ test("falls back to a partially matched object", () => {
27
27
  expect(registry.get({ foo: "bar", bar: "baz" })).toBe("blah");
28
28
  });
29
29
 
30
- test("uses more specific match if one exists", () => {
30
+ test("uses more specific match if one exists where more specific one is added last", () => {
31
31
  const query = { foo: "bar", metaData: { role: "baz" } };
32
32
  registry.set({ foo: "bar" }, "blah");
33
33
  expect(registry.get(query)).toBe("blah");
@@ -35,6 +35,13 @@ test("uses more specific match if one exists", () => {
35
35
  expect(registry.get(query)).toBe("stuff");
36
36
  });
37
37
 
38
+ test("uses more specific match if one exists where more specific one is added first", () => {
39
+ const query = { foo: "bar", metaData: { role: "baz" } };
40
+ registry.set({ foo: "bar", metaData: { role: "baz" } }, "stuff");
41
+ registry.set({ foo: "bar" }, "blah");
42
+ expect(registry.get(query)).toBe("stuff");
43
+ });
44
+
38
45
  test("works with seed data", () => {
39
46
  registry = new Registry([
40
47
  [{ type: "foo" }, "foo-bar"],
@@ -67,3 +74,61 @@ test("check if registry is empty", () => {
67
74
  expect(registry.isRegistryEmpty()).toBe(false);
68
75
  expect(emptyRegistry.isRegistryEmpty()).toBe(true);
69
76
  });
77
+
78
+ test("replacement only replaces exact matches, not fuzzy matches", () => {
79
+ registry.set({ foo: "bar" }, "exact-match");
80
+ registry.set({ foo: "bar", baz: "qux" }, "more-specific-match");
81
+
82
+ // Override the exact match - should only remove the exact match
83
+ registry.set({ foo: "bar" }, "new-exact-match");
84
+
85
+ // The exact match should be replaced
86
+ expect(registry.get({ foo: "bar" })).toBe("new-exact-match");
87
+
88
+ // The more specific match should still exist and be found by fuzzy matching
89
+ expect(registry.get({ foo: "bar", baz: "qux" })).toBe("more-specific-match");
90
+
91
+ // Now override the more specific match
92
+ registry.set({ foo: "bar", baz: "qux" }, "new-specific-match");
93
+
94
+ // The more specific match should be replaced
95
+ expect(registry.get({ foo: "bar", baz: "qux" })).toBe("new-specific-match");
96
+
97
+ // The exact match should still exist
98
+ expect(registry.get({ foo: "bar" })).toBe("new-exact-match");
99
+ });
100
+
101
+ test("logs debug message when initialSet has duplicate keys", () => {
102
+ const mockDebug = vi.fn();
103
+ const logger = { debug: mockDebug };
104
+
105
+ // Create registry with duplicate keys in initialSet
106
+ const registryWithDuplicates = new Registry<string>(
107
+ [
108
+ [{ type: "action" }, "first-value"],
109
+ [{ type: "action" }, "second-value"], // Duplicate - should trigger log
110
+ [{ type: "other" }, "other-value"],
111
+ [{ type: "action" }, "third-value"], // Another duplicate - should trigger log again
112
+ ],
113
+ logger,
114
+ );
115
+
116
+ // Should have logged twice for the two replacements
117
+ expect(mockDebug).toHaveBeenCalledTimes(2);
118
+
119
+ // Verify the log messages
120
+ expect(mockDebug).toHaveBeenNthCalledWith(
121
+ 1,
122
+ "Registry: Replacing existing entry for key ",
123
+ { type: "action" },
124
+ );
125
+ expect(mockDebug).toHaveBeenNthCalledWith(
126
+ 2,
127
+ "Registry: Replacing existing entry for key ",
128
+ { type: "action" },
129
+ );
130
+
131
+ // Verify the final value is the last one set
132
+ expect(registryWithDuplicates.get({ type: "action" })).toBe("third-value");
133
+ expect(registryWithDuplicates.get({ type: "other" })).toBe("other-value");
134
+ });
@@ -16,7 +16,13 @@ function traverseObj(
16
16
  const val: any = object[key];
17
17
  const nestedPath = [...path, key];
18
18
 
19
- if (typeof val === "object") {
19
+ /* Explicitly avoid traversing null values.
20
+ JavaScript's typeof null === "object" would otherwise cause the function to traverse null as an object
21
+ and throw an error.
22
+
23
+ Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null
24
+ */
25
+ if (typeof val === "object" && val !== null) {
20
26
  traverseObj(val, nestedPath, pairs);
21
27
  } else {
22
28
  pairs.set(nestedPath, val);
package/src/index.ts CHANGED
@@ -1,9 +1,14 @@
1
- import SortedArray from "sorted-array";
1
+ import { sort } from "fast-sort";
2
2
  import type { Matcher } from "./deep-partial-matcher";
3
3
  import { createObjectMatcher } from "./deep-partial-matcher";
4
4
 
5
5
  export { createObjectMatcher } from "./deep-partial-matcher";
6
6
 
7
+ /** Minimal logger interface for registry operations */
8
+ interface Logger {
9
+ debug?: (...args: Array<any>) => void;
10
+ }
11
+
7
12
  /** create a matcher function that matches exactly */
8
13
  function createBasicMatcher(seed: any): Matcher {
9
14
  /** a simple matcher function that only matches itself */
@@ -24,60 +29,99 @@ interface RegistryIndex<V> {
24
29
  matcher: Matcher;
25
30
  }
26
31
 
27
- /** create an empty sorted array using the matcher count */
28
- const createSortedArray = <V>() =>
29
- new SortedArray<RegistryIndex<V>>([], (c) => c.matcher.count);
30
-
31
32
  /**
32
33
  * A partial match registry is a map that uses an object to "match" against keys.
33
34
  * More specific matches take precedence over less specific ones.
34
35
  */
35
36
  export class Registry<V> {
36
- private store = createSortedArray<V>();
37
+ private store: Array<RegistryIndex<V>> = [];
38
+ private logger?: Logger;
37
39
 
38
- constructor(initialSet?: Array<[any, V]>) {
40
+ /**
41
+ * Creates a new Registry instance
42
+ *
43
+ * @param initialSet - Optional array of [key, value] tuples to populate the registry
44
+ * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)
45
+ */
46
+ constructor(initialSet?: Array<[any, V]>, logger?: Logger) {
47
+ this.logger = logger;
39
48
  initialSet?.forEach(([match, value]) => {
40
49
  this.set(match, value);
41
50
  });
42
51
  }
43
52
 
44
- /** Add match -> value mapping to the registry */
45
- set(match: any, value: V) {
53
+ /**
54
+ * Add match -> value mapping to the registry
55
+ *
56
+ * If an entry with the same specificity and matching key already exists, it will be replaced
57
+ * and a debug log will be emitted (if a logger is configured).
58
+ *
59
+ * @param match - The key to match against (can be a primitive or object)
60
+ * @param value - The value to associate with this key
61
+ */
62
+ set(match: any, value: V): void {
46
63
  const matcher =
47
64
  typeof match === "object"
48
65
  ? createObjectMatcher(match)
49
66
  : createBasicMatcher(match);
50
67
 
51
- this.store.insert({
68
+ // Find and remove any existing entry that matches this key
69
+ // Use matcher to check for matching keys (handles deep equality)
70
+ const existingIndex = this.store.findIndex(
71
+ (entry) => entry.matcher(match) && matcher(entry.key),
72
+ );
73
+ if (existingIndex !== -1) {
74
+ this.store.splice(existingIndex, 1);
75
+ this.logger?.debug?.(
76
+ "Registry: Replacing existing entry for key ",
77
+ match,
78
+ );
79
+ }
80
+
81
+ this.store.push({
52
82
  key: match,
53
83
  value,
54
84
  matcher,
55
85
  });
86
+
87
+ // Sort in descending order by matcher.count (highest specificity first)
88
+ this.store = sort(this.store).desc((entry) => entry.matcher.count);
56
89
  }
57
90
 
58
- /** Fetch the best match in the registry */
91
+ /**
92
+ * Fetch the best match in the registry
93
+ *
94
+ * Searches for the most specific entry that matches the given query.
95
+ * The registry is sorted by specificity (matcher.count) in descending order,
96
+ * so we iterate forward to find the highest specificity match first.
97
+ *
98
+ * @param query - The query object to match against registered keys
99
+ * @returns The value associated with the best matching key, or undefined if no match found
100
+ */
59
101
  get(query: any): V | undefined {
60
- for (const entry of this.store.array) {
102
+ // Store is sorted by matcher.count (descending), so iterate forward
103
+ for (const entry of this.store) {
61
104
  if (entry.matcher(query)) {
62
105
  return entry.value;
63
106
  }
64
107
  }
108
+ return undefined;
65
109
  }
66
110
 
67
111
  /** Loop over all entries and run callback */
68
112
  forEach(callbackfn: (value: RegistryIndex<V>) => void): void {
69
- for (const entry of this.store.array) {
113
+ for (const entry of this.store) {
70
114
  callbackfn(entry);
71
115
  }
72
116
  }
73
117
 
74
118
  /** Reset the items in the registry */
75
- clear() {
76
- this.store = createSortedArray<V>();
119
+ clear(): void {
120
+ this.store = [];
77
121
  }
78
122
 
79
123
  /** Check if the registry is empty*/
80
- isRegistryEmpty() {
81
- return this.store.array.length === 0;
124
+ isRegistryEmpty(): boolean {
125
+ return this.store.length === 0;
82
126
  }
83
127
  }
package/types/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import type { Matcher } from "./deep-partial-matcher";
2
2
  export { createObjectMatcher } from "./deep-partial-matcher";
3
+ /** Minimal logger interface for registry operations */
4
+ interface Logger {
5
+ debug?: (...args: Array<any>) => void;
6
+ }
3
7
  interface RegistryIndex<V> {
4
8
  /** The original object we wanted to match on */
5
9
  key: object;
@@ -14,10 +18,34 @@ interface RegistryIndex<V> {
14
18
  */
15
19
  export declare class Registry<V> {
16
20
  private store;
17
- constructor(initialSet?: Array<[any, V]>);
18
- /** Add match -> value mapping to the registry */
21
+ private logger?;
22
+ /**
23
+ * Creates a new Registry instance
24
+ *
25
+ * @param initialSet - Optional array of [key, value] tuples to populate the registry
26
+ * @param logger - Optional logger instance for debug logging (e.g., when entries are replaced)
27
+ */
28
+ constructor(initialSet?: Array<[any, V]>, logger?: Logger);
29
+ /**
30
+ * Add match -> value mapping to the registry
31
+ *
32
+ * If an entry with the same specificity and matching key already exists, it will be replaced
33
+ * and a debug log will be emitted (if a logger is configured).
34
+ *
35
+ * @param match - The key to match against (can be a primitive or object)
36
+ * @param value - The value to associate with this key
37
+ */
19
38
  set(match: any, value: V): void;
20
- /** Fetch the best match in the registry */
39
+ /**
40
+ * Fetch the best match in the registry
41
+ *
42
+ * Searches for the most specific entry that matches the given query.
43
+ * The registry is sorted by specificity (matcher.count) in descending order,
44
+ * so we iterate forward to find the highest specificity match first.
45
+ *
46
+ * @param query - The query object to match against registered keys
47
+ * @returns The value associated with the best matching key, or undefined if no match found
48
+ */
21
49
  get(query: any): V | undefined;
22
50
  /** Loop over all entries and run callback */
23
51
  forEach(callbackfn: (value: RegistryIndex<V>) => void): void;