@player-ui/external-state-plugin 1.0.0--canary.865.36694

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.
@@ -0,0 +1,756 @@
1
+ "use strict";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_with_holes(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
10
+ function _array_without_holes(arr) {
11
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
12
+ }
13
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
+ try {
15
+ var info = gen[key](arg);
16
+ var value = info.value;
17
+ } catch (error) {
18
+ reject(error);
19
+ return;
20
+ }
21
+ if (info.done) {
22
+ resolve(value);
23
+ } else {
24
+ Promise.resolve(value).then(_next, _throw);
25
+ }
26
+ }
27
+ function _async_to_generator(fn) {
28
+ return function() {
29
+ var self = this, args = arguments;
30
+ return new Promise(function(resolve, reject) {
31
+ var gen = fn.apply(self, args);
32
+ function _next(value) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
34
+ }
35
+ function _throw(err) {
36
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
37
+ }
38
+ _next(undefined);
39
+ });
40
+ };
41
+ }
42
+ function _class_call_check(instance, Constructor) {
43
+ if (!(instance instanceof Constructor)) {
44
+ throw new TypeError("Cannot call a class as a function");
45
+ }
46
+ }
47
+ function _defineProperties(target, props) {
48
+ for(var i = 0; i < props.length; i++){
49
+ var descriptor = props[i];
50
+ descriptor.enumerable = descriptor.enumerable || false;
51
+ descriptor.configurable = true;
52
+ if ("value" in descriptor) descriptor.writable = true;
53
+ Object.defineProperty(target, descriptor.key, descriptor);
54
+ }
55
+ }
56
+ function _create_class(Constructor, protoProps, staticProps) {
57
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
58
+ if (staticProps) _defineProperties(Constructor, staticProps);
59
+ return Constructor;
60
+ }
61
+ function _define_property(obj, key, value) {
62
+ if (key in obj) {
63
+ Object.defineProperty(obj, key, {
64
+ value: value,
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true
68
+ });
69
+ } else {
70
+ obj[key] = value;
71
+ }
72
+ return obj;
73
+ }
74
+ function _instanceof(left, right) {
75
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
76
+ return !!right[Symbol.hasInstance](left);
77
+ } else {
78
+ return left instanceof right;
79
+ }
80
+ }
81
+ function _iterable_to_array(iter) {
82
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
83
+ }
84
+ function _iterable_to_array_limit(arr, i) {
85
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
86
+ if (_i == null) return;
87
+ var _arr = [];
88
+ var _n = true;
89
+ var _d = false;
90
+ var _s, _e;
91
+ try {
92
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
93
+ _arr.push(_s.value);
94
+ if (i && _arr.length === i) break;
95
+ }
96
+ } catch (err) {
97
+ _d = true;
98
+ _e = err;
99
+ } finally{
100
+ try {
101
+ if (!_n && _i["return"] != null) _i["return"]();
102
+ } finally{
103
+ if (_d) throw _e;
104
+ }
105
+ }
106
+ return _arr;
107
+ }
108
+ function _non_iterable_rest() {
109
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
110
+ }
111
+ function _non_iterable_spread() {
112
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
113
+ }
114
+ function _object_spread(target) {
115
+ for(var i = 1; i < arguments.length; i++){
116
+ var source = arguments[i] != null ? arguments[i] : {};
117
+ var ownKeys = Object.keys(source);
118
+ if (typeof Object.getOwnPropertySymbols === "function") {
119
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
120
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
121
+ }));
122
+ }
123
+ ownKeys.forEach(function(key) {
124
+ _define_property(target, key, source[key]);
125
+ });
126
+ }
127
+ return target;
128
+ }
129
+ function _sliced_to_array(arr, i) {
130
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
131
+ }
132
+ function _to_consumable_array(arr) {
133
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
134
+ }
135
+ function _type_of(obj) {
136
+ "@swc/helpers - typeof";
137
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
138
+ }
139
+ function _unsupported_iterable_to_array(o, minLen) {
140
+ if (!o) return;
141
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
142
+ var n = Object.prototype.toString.call(o).slice(8, -1);
143
+ if (n === "Object" && o.constructor) n = o.constructor.name;
144
+ if (n === "Map" || n === "Set") return Array.from(n);
145
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
146
+ }
147
+ function _ts_generator(thisArg, body) {
148
+ var f, y, t, _ = {
149
+ label: 0,
150
+ sent: function() {
151
+ if (t[0] & 1) throw t[1];
152
+ return t[1];
153
+ },
154
+ trys: [],
155
+ ops: []
156
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
157
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
158
+ return this;
159
+ }), g;
160
+ function verb(n) {
161
+ return function(v) {
162
+ return step([
163
+ n,
164
+ v
165
+ ]);
166
+ };
167
+ }
168
+ function step(op) {
169
+ if (f) throw new TypeError("Generator is already executing.");
170
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
171
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
172
+ if (y = 0, t) op = [
173
+ op[0] & 2,
174
+ t.value
175
+ ];
176
+ switch(op[0]){
177
+ case 0:
178
+ case 1:
179
+ t = op;
180
+ break;
181
+ case 4:
182
+ _.label++;
183
+ return {
184
+ value: op[1],
185
+ done: false
186
+ };
187
+ case 5:
188
+ _.label++;
189
+ y = op[1];
190
+ op = [
191
+ 0
192
+ ];
193
+ continue;
194
+ case 7:
195
+ op = _.ops.pop();
196
+ _.trys.pop();
197
+ continue;
198
+ default:
199
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
200
+ _ = 0;
201
+ continue;
202
+ }
203
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
204
+ _.label = op[1];
205
+ break;
206
+ }
207
+ if (op[0] === 6 && _.label < t[1]) {
208
+ _.label = t[1];
209
+ t = op;
210
+ break;
211
+ }
212
+ if (t && _.label < t[2]) {
213
+ _.label = t[2];
214
+ _.ops.push(op);
215
+ break;
216
+ }
217
+ if (t[2]) _.ops.pop();
218
+ _.trys.pop();
219
+ continue;
220
+ }
221
+ op = body.call(thisArg, _);
222
+ } catch (e) {
223
+ op = [
224
+ 6,
225
+ e
226
+ ];
227
+ y = 0;
228
+ } finally{
229
+ f = t = 0;
230
+ }
231
+ if (op[0] & 5) throw op[1];
232
+ return {
233
+ value: op[0] ? op[1] : void 0,
234
+ done: true
235
+ };
236
+ }
237
+ }
238
+ var ExternalStatePlugin = function() {
239
+ var createNewSortInstance = function createNewSortInstance(opts) {
240
+ var comparer = castComparer(opts.comparer);
241
+ return function(arrayToSort) {
242
+ var ctx = Array.isArray(arrayToSort) && !opts.inPlaceSorting ? arrayToSort.slice() : arrayToSort;
243
+ return {
244
+ asc: function asc(sortBy) {
245
+ return sortArray(1, ctx, sortBy, comparer);
246
+ },
247
+ desc: function desc(sortBy) {
248
+ return sortArray(-1, ctx, sortBy, comparer);
249
+ },
250
+ by: function by(sortBy) {
251
+ return sortArray(1, ctx, sortBy, comparer);
252
+ }
253
+ };
254
+ };
255
+ };
256
+ 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
257
+ function dlv_es_default(t, e, l, n, r) {
258
+ for(e = e.split ? e.split(".") : e, n = 0; n < e.length; n++)t = t ? t[e[n]] : r;
259
+ return t === r ? l : t;
260
+ };
261
+ var createObjectMatcher = function createObjectMatcher(partialObj) {
262
+ var pairs = traverseObj(partialObj);
263
+ var matchFunction = function(searchObj) {
264
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
265
+ try {
266
+ for(var _iterator = Array.from(pairs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
267
+ var entry = _step.value;
268
+ var _entry = _sliced_to_array(entry, 2), path = _entry[0], value = _entry[1];
269
+ if (dlv_es_default(searchObj, path) !== value) {
270
+ return false;
271
+ }
272
+ }
273
+ } catch (err) {
274
+ _didIteratorError = true;
275
+ _iteratorError = err;
276
+ } finally{
277
+ try {
278
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
279
+ _iterator.return();
280
+ }
281
+ } finally{
282
+ if (_didIteratorError) {
283
+ throw _iteratorError;
284
+ }
285
+ }
286
+ }
287
+ return true;
288
+ };
289
+ matchFunction.count = pairs.size;
290
+ return matchFunction;
291
+ };
292
+ var createBasicMatcher = function createBasicMatcher(seed) {
293
+ var matcher = function(match) {
294
+ return seed === match;
295
+ };
296
+ matcher.count = 1;
297
+ return matcher;
298
+ };
299
+ var isExternal = // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts
300
+ function isExternal(state) {
301
+ return state.state_type === "EXTERNAL";
302
+ };
303
+ var isInProgress = function isInProgress(state) {
304
+ return state.status === "in-progress";
305
+ };
306
+ var __defProp = Object.defineProperty;
307
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
308
+ var __getOwnPropNames = Object.getOwnPropertyNames;
309
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
310
+ var __export = function(target, all) {
311
+ for(var name in all)__defProp(target, name, {
312
+ get: all[name],
313
+ enumerable: true
314
+ });
315
+ };
316
+ var __copyProps = function(to, from, except, desc) {
317
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
318
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
319
+ try {
320
+ var _loop = function() {
321
+ var key = _step.value;
322
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
323
+ get: function() {
324
+ return from[key];
325
+ },
326
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
327
+ });
328
+ };
329
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
330
+ } catch (err) {
331
+ _didIteratorError = true;
332
+ _iteratorError = err;
333
+ } finally{
334
+ try {
335
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
336
+ _iterator.return();
337
+ }
338
+ } finally{
339
+ if (_didIteratorError) {
340
+ throw _iteratorError;
341
+ }
342
+ }
343
+ }
344
+ }
345
+ return to;
346
+ };
347
+ var __toCommonJS = function(mod) {
348
+ return __copyProps(__defProp({}, "__esModule", {
349
+ value: true
350
+ }), mod);
351
+ };
352
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/index.ts
353
+ var src_exports = {};
354
+ __export(src_exports, {
355
+ ExternalStatePlugin: function() {
356
+ return ExternalStatePlugin;
357
+ }
358
+ });
359
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/fast-sort@3.4.1/node_modules/fast-sort/dist/sort.mjs
360
+ var castComparer = function castComparer(comparer) {
361
+ return function(a, b, order) {
362
+ return comparer(a, b, order) * order;
363
+ };
364
+ };
365
+ var throwInvalidConfigErrorIfTrue = function throwInvalidConfigErrorIfTrue(condition, context) {
366
+ if (condition) throw Error("Invalid sort config: " + context);
367
+ };
368
+ var unpackObjectSorter = function unpackObjectSorter(sortByObj) {
369
+ var _a = sortByObj || {}, asc = _a.asc, desc = _a.desc;
370
+ var order = asc ? 1 : -1;
371
+ var sortBy = asc || desc;
372
+ throwInvalidConfigErrorIfTrue(!sortBy, "Expected `asc` or `desc` property");
373
+ throwInvalidConfigErrorIfTrue(asc && desc, "Ambiguous object with `asc` and `desc` config properties");
374
+ var comparer = sortByObj.comparer && castComparer(sortByObj.comparer);
375
+ return {
376
+ order: order,
377
+ sortBy: sortBy,
378
+ comparer: comparer
379
+ };
380
+ };
381
+ var multiPropertySorterProvider = function multiPropertySorterProvider(defaultComparer2) {
382
+ return function multiPropertySorter(sortBy, sortByArr, depth, order, comparer, a, b) {
383
+ var valA;
384
+ var valB;
385
+ if (typeof sortBy === "string") {
386
+ valA = a[sortBy];
387
+ valB = b[sortBy];
388
+ } else if (typeof sortBy === "function") {
389
+ valA = sortBy(a);
390
+ valB = sortBy(b);
391
+ } else {
392
+ var objectSorterConfig = unpackObjectSorter(sortBy);
393
+ return multiPropertySorter(objectSorterConfig.sortBy, sortByArr, depth, objectSorterConfig.order, objectSorterConfig.comparer || defaultComparer2, a, b);
394
+ }
395
+ var equality = comparer(valA, valB, order);
396
+ if ((equality === 0 || valA == null && valB == null) && sortByArr.length > depth) {
397
+ return multiPropertySorter(sortByArr[depth], sortByArr, depth + 1, order, comparer, a, b);
398
+ }
399
+ return equality;
400
+ };
401
+ };
402
+ function getSortStrategy(sortBy, comparer, order) {
403
+ if (sortBy === void 0 || sortBy === true) {
404
+ return function(a, b) {
405
+ return comparer(a, b, order);
406
+ };
407
+ }
408
+ if (typeof sortBy === "string") {
409
+ throwInvalidConfigErrorIfTrue(sortBy.includes("."), "String syntax not allowed for nested properties.");
410
+ return function(a, b) {
411
+ return comparer(a[sortBy], b[sortBy], order);
412
+ };
413
+ }
414
+ if (typeof sortBy === "function") {
415
+ return function(a, b) {
416
+ return comparer(sortBy(a), sortBy(b), order);
417
+ };
418
+ }
419
+ if (Array.isArray(sortBy)) {
420
+ var multiPropSorter_1 = multiPropertySorterProvider(comparer);
421
+ return function(a, b) {
422
+ return multiPropSorter_1(sortBy[0], sortBy, 1, order, comparer, a, b);
423
+ };
424
+ }
425
+ var objectSorterConfig = unpackObjectSorter(sortBy);
426
+ return getSortStrategy(objectSorterConfig.sortBy, objectSorterConfig.comparer || comparer, objectSorterConfig.order);
427
+ }
428
+ var sortArray = function sortArray(order, ctx, sortBy, comparer) {
429
+ var _a;
430
+ if (!Array.isArray(ctx)) {
431
+ return ctx;
432
+ }
433
+ if (Array.isArray(sortBy) && sortBy.length < 2) {
434
+ _a = sortBy, sortBy = _a[0];
435
+ }
436
+ return ctx.sort(getSortStrategy(sortBy, comparer, order));
437
+ };
438
+ var defaultComparer = function defaultComparer(a, b, order) {
439
+ if (a == null) return order;
440
+ if (b == null) return -order;
441
+ if ((typeof a === "undefined" ? "undefined" : _type_of(a)) !== (typeof b === "undefined" ? "undefined" : _type_of(b))) {
442
+ return (typeof a === "undefined" ? "undefined" : _type_of(a)) < (typeof b === "undefined" ? "undefined" : _type_of(b)) ? -1 : 1;
443
+ }
444
+ if (a < b) return -1;
445
+ if (a > b) return 1;
446
+ return 0;
447
+ };
448
+ var sort = createNewSortInstance({
449
+ comparer: defaultComparer
450
+ });
451
+ var inPlaceSort = createNewSortInstance({
452
+ comparer: defaultComparer,
453
+ inPlaceSorting: true
454
+ });
455
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+partial-match-registry@0.0.0/node_modules/@player-ui/partial-match-registry/dist/index.mjs
456
+ function traverseObj(object) {
457
+ var path = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [], pairs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Map();
458
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
459
+ try {
460
+ for(var _iterator = Object.keys(object)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
461
+ var key = _step.value;
462
+ var val = object[key];
463
+ var nestedPath = _to_consumable_array(path).concat([
464
+ key
465
+ ]);
466
+ if ((typeof val === "undefined" ? "undefined" : _type_of(val)) === "object" && val !== null) {
467
+ traverseObj(val, nestedPath, pairs);
468
+ } else {
469
+ pairs.set(nestedPath, val);
470
+ }
471
+ }
472
+ } catch (err) {
473
+ _didIteratorError = true;
474
+ _iteratorError = err;
475
+ } finally{
476
+ try {
477
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
478
+ _iterator.return();
479
+ }
480
+ } finally{
481
+ if (_didIteratorError) {
482
+ throw _iteratorError;
483
+ }
484
+ }
485
+ }
486
+ return pairs;
487
+ }
488
+ var Registry = /*#__PURE__*/ function() {
489
+ function Registry(initialSet, logger) {
490
+ var _this = this;
491
+ _class_call_check(this, Registry);
492
+ this.store = [];
493
+ this.logger = logger;
494
+ initialSet === null || initialSet === void 0 ? void 0 : initialSet.forEach(function(param) {
495
+ var _param = _sliced_to_array(param, 2), match = _param[0], value = _param[1];
496
+ _this.set(match, value);
497
+ });
498
+ }
499
+ _create_class(Registry, [
500
+ {
501
+ /**
502
+ * Add match -> value mapping to the registry
503
+ *
504
+ * If an entry with the same specificity and matching key already exists, it will be replaced
505
+ * and a debug log will be emitted (if a logger is configured).
506
+ *
507
+ * @param match - The key to match against (can be a primitive or object)
508
+ * @param value - The value to associate with this key
509
+ */ key: "set",
510
+ value: function set(match, value) {
511
+ var matcher = (typeof match === "undefined" ? "undefined" : _type_of(match)) === "object" ? createObjectMatcher(match) : createBasicMatcher(match);
512
+ var existingIndex = this.store.findIndex(function(entry) {
513
+ return entry.matcher(match) && matcher(entry.key);
514
+ });
515
+ if (existingIndex !== -1) {
516
+ var _this_logger_debug, _this_logger;
517
+ this.store.splice(existingIndex, 1);
518
+ (_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);
519
+ }
520
+ this.store.push({
521
+ key: match,
522
+ value: value,
523
+ matcher: matcher
524
+ });
525
+ this.store = sort(this.store).desc(function(entry) {
526
+ return entry.matcher.count;
527
+ });
528
+ }
529
+ },
530
+ {
531
+ /**
532
+ * Fetch the best match in the registry
533
+ *
534
+ * Searches for the most specific entry that matches the given query.
535
+ * The registry is sorted by specificity (matcher.count) in descending order,
536
+ * so we iterate forward to find the highest specificity match first.
537
+ *
538
+ * @param query - The query object to match against registered keys
539
+ * @returns The value associated with the best matching key, or undefined if no match found
540
+ */ key: "get",
541
+ value: function get(query) {
542
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
543
+ try {
544
+ for(var _iterator = this.store[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
545
+ var entry = _step.value;
546
+ if (entry.matcher(query)) {
547
+ return entry.value;
548
+ }
549
+ }
550
+ } catch (err) {
551
+ _didIteratorError = true;
552
+ _iteratorError = err;
553
+ } finally{
554
+ try {
555
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
556
+ _iterator.return();
557
+ }
558
+ } finally{
559
+ if (_didIteratorError) {
560
+ throw _iteratorError;
561
+ }
562
+ }
563
+ }
564
+ return void 0;
565
+ }
566
+ },
567
+ {
568
+ /** Loop over all entries and run callback */ key: "forEach",
569
+ value: function forEach(callbackfn) {
570
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
571
+ try {
572
+ for(var _iterator = this.store[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
573
+ var entry = _step.value;
574
+ callbackfn(entry);
575
+ }
576
+ } catch (err) {
577
+ _didIteratorError = true;
578
+ _iteratorError = err;
579
+ } finally{
580
+ try {
581
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
582
+ _iterator.return();
583
+ }
584
+ } finally{
585
+ if (_didIteratorError) {
586
+ throw _iteratorError;
587
+ }
588
+ }
589
+ }
590
+ }
591
+ },
592
+ {
593
+ /** Reset the items in the registry */ key: "clear",
594
+ value: function clear() {
595
+ this.store = [];
596
+ }
597
+ },
598
+ {
599
+ /** Check if the registry is empty*/ key: "isRegistryEmpty",
600
+ value: function isRegistryEmpty() {
601
+ return this.store.length === 0;
602
+ }
603
+ }
604
+ ]);
605
+ return Registry;
606
+ }();
607
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/external-state/core/src/symbols.ts
608
+ var ExternalStatePluginSymbol = Symbol.for("@player-ui/ExternalStatePlugin");
609
+ var _ExternalStatePlugin = /*#__PURE__*/ function() {
610
+ function _ExternalStatePlugin(handlers) {
611
+ _class_call_check(this, _ExternalStatePlugin);
612
+ this.name = "ExternalStatePlugin";
613
+ this.symbol = _ExternalStatePlugin.Symbol;
614
+ this.handlers = handlers;
615
+ }
616
+ _create_class(_ExternalStatePlugin, [
617
+ {
618
+ key: "apply",
619
+ value: function apply(player) {
620
+ var _this = this;
621
+ var isFirstInstance = this.createRegistry(player);
622
+ this.registerHandlers(player);
623
+ if (!isFirstInstance) {
624
+ return;
625
+ }
626
+ player.hooks.flowController.tap(this.name, function(flowController) {
627
+ flowController.hooks.flow.tap(_this.name, function(flow) {
628
+ flow.hooks.afterTransition.tap(_this.name, function(flowInstance) {
629
+ return _async_to_generator(function() {
630
+ var toState, currentState, _this_registry, handler, transitionValue, _latestState_controllers_flow_current_currentState, _latestState_controllers_flow_current, latestState, error;
631
+ return _ts_generator(this, function(_state) {
632
+ switch(_state.label){
633
+ case 0:
634
+ toState = flowInstance.currentState;
635
+ currentState = player.getState();
636
+ if (!(toState && toState.value && isExternal(toState.value) && isInProgress(currentState))) return [
637
+ 3,
638
+ 4
639
+ ];
640
+ _state.label = 1;
641
+ case 1:
642
+ _state.trys.push([
643
+ 1,
644
+ 3,
645
+ ,
646
+ 4
647
+ ]);
648
+ handler = (_this_registry = this.registry) === null || _this_registry === void 0 ? void 0 : _this_registry.get(toState.value);
649
+ return [
650
+ 4,
651
+ handler === null || handler === void 0 ? void 0 : handler(toState.value, currentState.controllers)
652
+ ];
653
+ case 2:
654
+ transitionValue = _state.sent();
655
+ if (transitionValue !== void 0) {
656
+ ;
657
+ latestState = player.getState();
658
+ if (isInProgress(latestState) && ((_latestState_controllers_flow_current = latestState.controllers.flow.current) === null || _latestState_controllers_flow_current === void 0 ? void 0 : (_latestState_controllers_flow_current_currentState = _latestState_controllers_flow_current.currentState) === null || _latestState_controllers_flow_current_currentState === void 0 ? void 0 : _latestState_controllers_flow_current_currentState.name) === toState.name) {
659
+ latestState.controllers.flow.transition(transitionValue);
660
+ } else {
661
+ player.logger.warn("External state resolved with [".concat(transitionValue, "], but Player already navigated away from [").concat(toState.name, "]"));
662
+ }
663
+ }
664
+ return [
665
+ 3,
666
+ 4
667
+ ];
668
+ case 3:
669
+ error = _state.sent();
670
+ if (_instanceof(error, Error)) {
671
+ currentState.fail(error);
672
+ }
673
+ return [
674
+ 3,
675
+ 4
676
+ ];
677
+ case 4:
678
+ return [
679
+ 2
680
+ ];
681
+ }
682
+ });
683
+ }).call(_this);
684
+ });
685
+ });
686
+ });
687
+ }
688
+ },
689
+ {
690
+ /**
691
+ * Create or share the registry for this plugin instance.
692
+ *
693
+ * Uses the Player's plugin registry to find if another instance of ExternalStatePlugin
694
+ * has already been registered. If found, this instance will share that plugin's registry.
695
+ * Otherwise, this instance creates a new registry.
696
+ */ key: "createRegistry",
697
+ value: function createRegistry(player) {
698
+ var existing = player.findPlugin(ExternalStatePluginSymbol);
699
+ if (existing && existing !== this) {
700
+ this.registry = existing.registry;
701
+ return false;
702
+ }
703
+ this.registry = new Registry(void 0, player.logger);
704
+ return true;
705
+ }
706
+ },
707
+ {
708
+ /**
709
+ * Register this plugin's handlers to the shared registry.
710
+ *
711
+ * If a handler with the same specificity already exists, it will be replaced
712
+ * and a debug log will be emitted (accessible via player.logger.debug).
713
+ */ key: "registerHandlers",
714
+ value: function registerHandlers(player) {
715
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
716
+ try {
717
+ for(var _iterator = this.handlers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
718
+ var handler = _step.value;
719
+ var _handler_match, _this_registry;
720
+ if ((_handler_match = handler.match) === null || _handler_match === void 0 ? void 0 : _handler_match.ref) {
721
+ var _handler_match1;
722
+ player.logger.warn("An ExternalStateHandler contains a superfluous 'match.ref' property. 'match.ref' will be ignored. 'ref' will be used instead. Handler: ".concat(JSON.stringify({
723
+ ref: handler.ref,
724
+ match: handler.match
725
+ })));
726
+ (_handler_match1 = handler.match) === null || _handler_match1 === void 0 ? true : delete _handler_match1["ref"];
727
+ continue;
728
+ }
729
+ (_this_registry = this.registry) === null || _this_registry === void 0 ? void 0 : _this_registry.set(_object_spread({
730
+ ref: handler.ref
731
+ }, handler.match), handler.handlerFunction);
732
+ }
733
+ } catch (err) {
734
+ _didIteratorError = true;
735
+ _iteratorError = err;
736
+ } finally{
737
+ try {
738
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
739
+ _iterator.return();
740
+ }
741
+ } finally{
742
+ if (_didIteratorError) {
743
+ throw _iteratorError;
744
+ }
745
+ }
746
+ }
747
+ }
748
+ }
749
+ ]);
750
+ return _ExternalStatePlugin;
751
+ }();
752
+ /** Symbol used to identify and find existing instances of this plugin */ _ExternalStatePlugin.Symbol = ExternalStatePluginSymbol;
753
+ var ExternalStatePlugin = _ExternalStatePlugin;
754
+ return __toCommonJS(src_exports);
755
+ }();
756
+ //# sourceMappingURL=index.global.js.map