@player-devtools/basic-plugin 1.0.1-next.0 → 1.1.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -185,6 +185,9 @@ function _super_prop_base(object, property) {
185
185
  }
186
186
  return object;
187
187
  }
188
+ function _to_array(arr) {
189
+ return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
190
+ }
188
191
  function _to_consumable_array(arr) {
189
192
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
190
193
  }
@@ -595,6 +598,31 @@ var BasicDevtoolsPlugin = function() {
595
598
  return (c === "x" ? r : r & 3 | 8).toString(16);
596
599
  });
597
600
  };
601
+ var equalToOrIn = // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/tapable-ts@0.2.4/node_modules/tapable-ts/dist/hooks.mjs
602
+ function equalToOrIn(value, check) {
603
+ if (Array.isArray(check)) {
604
+ return check.includes(value);
605
+ }
606
+ return check === value;
607
+ };
608
+ var callTap = function callTap(tap, args, ctx) {
609
+ var _tap;
610
+ if (tap.context) {
611
+ var _tap1;
612
+ return (_tap1 = tap).callback.apply(_tap1, [
613
+ ctx
614
+ ].concat(_to_consumable_array(args)));
615
+ }
616
+ return (_tap = tap).callback.apply(_tap, _to_consumable_array(args));
617
+ };
618
+ var getContextPlugin = function getContextPlugin(player) {
619
+ var existing = player.findPlugin(ContextPluginSymbol);
620
+ var plugin = existing !== null && existing !== void 0 ? existing : new ContextPlugin();
621
+ if (!existing) {
622
+ player.registerPlugin(plugin);
623
+ }
624
+ return plugin;
625
+ };
598
626
  var __defProp = Object.defineProperty;
599
627
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
600
628
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -646,6 +674,9 @@ var BasicDevtoolsPlugin = function() {
646
674
  __export(src_exports, {
647
675
  BasicDevtoolsPlugin: function() {
648
676
  return BasicDevtoolsPlugin;
677
+ },
678
+ playerConfigContextKey: function() {
679
+ return playerConfigContextKey;
649
680
  }
650
681
  });
651
682
  // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-devtools+basic-plugin-content@0.0.0/node_modules/@player-devtools/basic-plugin-content/dist/index.mjs
@@ -1441,7 +1472,7 @@ var BasicDevtoolsPlugin = function() {
1441
1472
  playerConfig: {}
1442
1473
  }
1443
1474
  };
1444
- var PLUGIN_VERSION = true ? "1.0.1-next.0" : "unstamped";
1475
+ var PLUGIN_VERSION = true ? "1.1.0-next.0" : "unstamped";
1445
1476
  var _obj;
1446
1477
  var BasicPluginData = {
1447
1478
  id: PLUGIN_ID,
@@ -2319,6 +2350,1173 @@ var BasicDevtoolsPlugin = function() {
2319
2350
  ]);
2320
2351
  return DevtoolsPlugin;
2321
2352
  }();
2353
+ var InterceptionManager = /*#__PURE__*/ function() {
2354
+ function InterceptionManager() {
2355
+ _class_call_check(this, InterceptionManager);
2356
+ this.interceptions = [];
2357
+ this.interceptionKeySet = /* @__PURE__ */ new Set();
2358
+ }
2359
+ _create_class(InterceptionManager, [
2360
+ {
2361
+ key: "isUsed",
2362
+ value: function isUsed() {
2363
+ return this.interceptions.length > 0;
2364
+ }
2365
+ },
2366
+ {
2367
+ key: "intercept",
2368
+ value: function intercept(int) {
2369
+ var _this = this;
2370
+ this.interceptions.push(int);
2371
+ Object.keys(int).forEach(function(s) {
2372
+ _this.interceptionKeySet.add(s);
2373
+ });
2374
+ }
2375
+ },
2376
+ {
2377
+ key: "tap",
2378
+ value: function tap(tap) {
2379
+ if (this.interceptionKeySet.has("tap")) {
2380
+ this.interceptions.forEach(function(i) {
2381
+ var _a;
2382
+ (_a = i.tap) == null ? void 0 : _a.call(i, tap);
2383
+ });
2384
+ }
2385
+ }
2386
+ },
2387
+ {
2388
+ key: "call",
2389
+ value: function call(ctx) {
2390
+ for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2391
+ args[_key - 1] = arguments[_key];
2392
+ }
2393
+ if (this.interceptionKeySet.has("call")) {
2394
+ this.interceptions.forEach(function(i) {
2395
+ var _a, _b;
2396
+ if (i.context) {
2397
+ var _a1;
2398
+ (_a = i.call) == null ? void 0 : (_a1 = _a).call.apply(_a1, [
2399
+ i,
2400
+ ctx
2401
+ ].concat(_to_consumable_array(args)));
2402
+ } else {
2403
+ var _b1;
2404
+ (_b = i.call) == null ? void 0 : (_b1 = _b).call.apply(_b1, [
2405
+ i
2406
+ ].concat(_to_consumable_array(args)));
2407
+ }
2408
+ });
2409
+ }
2410
+ }
2411
+ },
2412
+ {
2413
+ key: "loop",
2414
+ value: function loop() {
2415
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
2416
+ args[_key] = arguments[_key];
2417
+ }
2418
+ if (this.interceptionKeySet.has("loop")) {
2419
+ this.interceptions.forEach(function(i) {
2420
+ var _a;
2421
+ var _a1;
2422
+ (_a1 = i.loop) == null ? void 0 : (_a = _a1).call.apply(_a, [
2423
+ i
2424
+ ].concat(_to_consumable_array(args)));
2425
+ });
2426
+ }
2427
+ }
2428
+ },
2429
+ {
2430
+ key: "error",
2431
+ value: function error(err) {
2432
+ if (this.interceptionKeySet.has("error")) {
2433
+ if (_instanceof(err, Error)) {
2434
+ var asError = err;
2435
+ this.interceptions.forEach(function(i) {
2436
+ var _a;
2437
+ (_a = i.error) == null ? void 0 : _a.call(i, asError);
2438
+ });
2439
+ }
2440
+ }
2441
+ }
2442
+ },
2443
+ {
2444
+ key: "result",
2445
+ value: function result(r) {
2446
+ if (this.interceptionKeySet.has("result")) {
2447
+ this.interceptions.forEach(function(i) {
2448
+ var _a;
2449
+ (_a = i.result) == null ? void 0 : _a.call(i, r);
2450
+ });
2451
+ }
2452
+ }
2453
+ },
2454
+ {
2455
+ key: "done",
2456
+ value: function done() {
2457
+ if (this.interceptionKeySet.has("done")) {
2458
+ this.interceptions.forEach(function(i) {
2459
+ var _a;
2460
+ (_a = i.done) == null ? void 0 : _a.call(i);
2461
+ });
2462
+ }
2463
+ }
2464
+ }
2465
+ ]);
2466
+ return InterceptionManager;
2467
+ }();
2468
+ var Hook = /*#__PURE__*/ function() {
2469
+ function Hook() {
2470
+ _class_call_check(this, Hook);
2471
+ this.taps = [];
2472
+ this.interceptions = new InterceptionManager();
2473
+ }
2474
+ _create_class(Hook, [
2475
+ {
2476
+ key: "tap",
2477
+ value: function tap(options, callback) {
2478
+ var resolvedOptions = typeof options === "string" ? {
2479
+ name: options,
2480
+ context: false
2481
+ } : _object_spread({
2482
+ context: false
2483
+ }, options);
2484
+ var key = Symbol(resolvedOptions.name);
2485
+ var tap = _object_spread_props(_object_spread({
2486
+ key: key
2487
+ }, resolvedOptions), {
2488
+ callback: callback
2489
+ });
2490
+ if (tap.before) {
2491
+ var insertionIndex = this.taps.length;
2492
+ var beforeSet = new Set(Array.isArray(tap.before) ? tap.before : [
2493
+ tap.before
2494
+ ]);
2495
+ for(insertionIndex; insertionIndex > 0 && beforeSet.size > 0; insertionIndex--){
2496
+ var t = this.taps[insertionIndex - 1];
2497
+ if (beforeSet.has(t.name)) {
2498
+ beforeSet.delete(t.name);
2499
+ }
2500
+ if (t.before && equalToOrIn(tap.name, t.before)) {
2501
+ break;
2502
+ }
2503
+ }
2504
+ this.taps.splice(insertionIndex, 0, tap);
2505
+ } else {
2506
+ this.taps.push(tap);
2507
+ }
2508
+ this.interceptions.tap(tap);
2509
+ return tap;
2510
+ }
2511
+ },
2512
+ {
2513
+ key: "untap",
2514
+ value: function untap(tap) {
2515
+ this.taps = this.taps.filter(function(t) {
2516
+ return t.key !== tap.key;
2517
+ });
2518
+ }
2519
+ },
2520
+ {
2521
+ key: "isUsed",
2522
+ value: function isUsed() {
2523
+ return this.taps.length > 0 || this.interceptions.isUsed();
2524
+ }
2525
+ },
2526
+ {
2527
+ key: "intercept",
2528
+ value: function intercept(int) {
2529
+ this.interceptions.intercept(int);
2530
+ }
2531
+ }
2532
+ ]);
2533
+ return Hook;
2534
+ }();
2535
+ var SyncHook = /*#__PURE__*/ function(Hook) {
2536
+ _inherits(SyncHook, Hook);
2537
+ var _super = _create_super(SyncHook);
2538
+ function SyncHook() {
2539
+ _class_call_check(this, SyncHook);
2540
+ return _super.apply(this, arguments);
2541
+ }
2542
+ _create_class(SyncHook, [
2543
+ {
2544
+ key: "call",
2545
+ value: function call() {
2546
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
2547
+ args[_key] = arguments[_key];
2548
+ }
2549
+ var _this_interceptions;
2550
+ if (!this.isUsed()) {
2551
+ return;
2552
+ }
2553
+ var ctx = {};
2554
+ (_this_interceptions = this.interceptions).call.apply(_this_interceptions, [
2555
+ ctx
2556
+ ].concat(_to_consumable_array(args)));
2557
+ try {
2558
+ this.taps.forEach(function(t) {
2559
+ callTap(t, args, ctx);
2560
+ });
2561
+ } catch (err) {
2562
+ this.interceptions.error(err);
2563
+ throw err;
2564
+ }
2565
+ this.interceptions.done();
2566
+ }
2567
+ }
2568
+ ]);
2569
+ return SyncHook;
2570
+ }(Hook);
2571
+ var SyncWaterfallHook = /*#__PURE__*/ function(Hook) {
2572
+ _inherits(SyncWaterfallHook, Hook);
2573
+ var _super = _create_super(SyncWaterfallHook);
2574
+ function SyncWaterfallHook() {
2575
+ _class_call_check(this, SyncWaterfallHook);
2576
+ return _super.apply(this, arguments);
2577
+ }
2578
+ _create_class(SyncWaterfallHook, [
2579
+ {
2580
+ key: "call",
2581
+ value: function call() {
2582
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
2583
+ args[_key] = arguments[_key];
2584
+ }
2585
+ var _this_interceptions;
2586
+ var ctx = {};
2587
+ (_this_interceptions = this.interceptions).call.apply(_this_interceptions, [
2588
+ ctx
2589
+ ].concat(_to_consumable_array(args)));
2590
+ var _args = _to_array(args), rtn = _args[0], rest = _args.slice(1);
2591
+ for(var tapIndex = 0; tapIndex < this.taps.length; tapIndex += 1){
2592
+ var tapValue = callTap(this.taps[tapIndex], [
2593
+ rtn
2594
+ ].concat(_to_consumable_array(rest)), ctx);
2595
+ if (tapValue !== void 0) {
2596
+ rtn = tapValue;
2597
+ }
2598
+ }
2599
+ this.interceptions.result(rtn);
2600
+ return rtn;
2601
+ }
2602
+ }
2603
+ ]);
2604
+ return SyncWaterfallHook;
2605
+ }(Hook);
2606
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+context-plugin@1.3.0_at_player-ui_player_1.3.0/node_modules/@player-ui/context-plugin/dist/index.mjs
2607
+ var KEY_NAMESPACE = "player-ui.context.";
2608
+ var defineContextKey = function(name, description) {
2609
+ return {
2610
+ symbol: Symbol.for("".concat(KEY_NAMESPACE).concat(name)),
2611
+ description: description
2612
+ };
2613
+ };
2614
+ var nameOfContextKey = function(key) {
2615
+ var k = Symbol.keyFor(key.symbol);
2616
+ if (!k || !k.startsWith(KEY_NAMESPACE)) return void 0;
2617
+ return k.slice(KEY_NAMESPACE.length);
2618
+ };
2619
+ var deepFreezeEntry = function(entry) {
2620
+ Object.freeze(entry);
2621
+ return entry;
2622
+ };
2623
+ var tombstone = function(description) {
2624
+ return function() {
2625
+ throw new Error('[ContextPlugin] Action "'.concat(description, '" is no longer valid — its flow has ended'));
2626
+ };
2627
+ };
2628
+ var tombstoneFunctions = function(value, description) {
2629
+ if (typeof value === "function") {
2630
+ return tombstone(description);
2631
+ }
2632
+ if (Array.isArray(value)) {
2633
+ return value.map(function(item) {
2634
+ return tombstoneFunctions(item, description);
2635
+ });
2636
+ }
2637
+ if (value !== null && typeof value === "object") {
2638
+ var out = {};
2639
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2640
+ try {
2641
+ for(var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2642
+ var _step_value = _sliced_to_array(_step.value, 2), k = _step_value[0], v = _step_value[1];
2643
+ out[k] = tombstoneFunctions(v, description);
2644
+ }
2645
+ } catch (err) {
2646
+ _didIteratorError = true;
2647
+ _iteratorError = err;
2648
+ } finally{
2649
+ try {
2650
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2651
+ _iterator.return();
2652
+ }
2653
+ } finally{
2654
+ if (_didIteratorError) {
2655
+ throw _iteratorError;
2656
+ }
2657
+ }
2658
+ }
2659
+ return out;
2660
+ }
2661
+ return value;
2662
+ };
2663
+ var ContextStore = /*#__PURE__*/ function() {
2664
+ function ContextStore() {
2665
+ _class_call_check(this, ContextStore);
2666
+ this.entries = /* @__PURE__ */ new Map();
2667
+ this.dependents = /* @__PURE__ */ new Map();
2668
+ }
2669
+ _create_class(ContextStore, [
2670
+ {
2671
+ key: "register",
2672
+ value: function register(key) {
2673
+ if (this.entries.has(key.symbol)) {
2674
+ return false;
2675
+ }
2676
+ this.entries.set(key.symbol, {
2677
+ key: key,
2678
+ hasLiteral: false
2679
+ });
2680
+ return true;
2681
+ }
2682
+ },
2683
+ {
2684
+ key: "set",
2685
+ value: function set(key, value) {
2686
+ var existing = this.entries.get(key.symbol);
2687
+ if (existing) {
2688
+ existing.hasLiteral = true;
2689
+ existing.literal = value;
2690
+ existing.key = key;
2691
+ } else {
2692
+ this.entries.set(key.symbol, {
2693
+ key: key,
2694
+ hasLiteral: true,
2695
+ literal: value
2696
+ });
2697
+ }
2698
+ }
2699
+ },
2700
+ {
2701
+ key: "registerTransform",
2702
+ value: function registerTransform(key, transform) {
2703
+ var _existing_transform, _existing;
2704
+ var existing = this.entries.get(key.symbol);
2705
+ var previousSources = (_existing = existing) === null || _existing === void 0 ? void 0 : (_existing_transform = _existing.transform) === null || _existing_transform === void 0 ? void 0 : _existing_transform.sources;
2706
+ if (previousSources) {
2707
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2708
+ try {
2709
+ for(var _iterator = previousSources[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2710
+ var src = _step.value;
2711
+ var _this_dependents_get;
2712
+ (_this_dependents_get = this.dependents.get(src.symbol)) === null || _this_dependents_get === void 0 ? void 0 : _this_dependents_get.delete(key.symbol);
2713
+ }
2714
+ } catch (err) {
2715
+ _didIteratorError = true;
2716
+ _iteratorError = err;
2717
+ } finally{
2718
+ try {
2719
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2720
+ _iterator.return();
2721
+ }
2722
+ } finally{
2723
+ if (_didIteratorError) {
2724
+ throw _iteratorError;
2725
+ }
2726
+ }
2727
+ }
2728
+ }
2729
+ var stored = {
2730
+ sources: transform.sources,
2731
+ compute: transform.compute
2732
+ };
2733
+ if (existing) {
2734
+ existing.transform = stored;
2735
+ existing.key = key;
2736
+ } else {
2737
+ this.entries.set(key.symbol, {
2738
+ key: key,
2739
+ hasLiteral: false,
2740
+ transform: stored
2741
+ });
2742
+ }
2743
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2744
+ try {
2745
+ for(var _iterator1 = transform.sources[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2746
+ var src1 = _step1.value;
2747
+ var set2 = this.dependents.get(src1.symbol);
2748
+ if (!set2) {
2749
+ set2 = /* @__PURE__ */ new Set();
2750
+ this.dependents.set(src1.symbol, set2);
2751
+ }
2752
+ set2.add(key.symbol);
2753
+ }
2754
+ } catch (err) {
2755
+ _didIteratorError1 = true;
2756
+ _iteratorError1 = err;
2757
+ } finally{
2758
+ try {
2759
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2760
+ _iterator1.return();
2761
+ }
2762
+ } finally{
2763
+ if (_didIteratorError1) {
2764
+ throw _iteratorError1;
2765
+ }
2766
+ }
2767
+ }
2768
+ return {
2769
+ previousSources: previousSources
2770
+ };
2771
+ }
2772
+ },
2773
+ {
2774
+ key: "get",
2775
+ value: function get(key) {
2776
+ return this.compute(key.symbol);
2777
+ }
2778
+ },
2779
+ {
2780
+ key: "has",
2781
+ value: function has(key) {
2782
+ var entry = this.entries.get(key.symbol);
2783
+ return Boolean(entry && (entry.hasLiteral || entry.transform));
2784
+ }
2785
+ },
2786
+ {
2787
+ /** Return the keys that depend on the given source key (direct dependents only). */ key: "dependentsOf",
2788
+ value: function dependentsOf(sourceSymbol) {
2789
+ var set2 = this.dependents.get(sourceSymbol);
2790
+ if (!set2 || set2.size === 0) {
2791
+ return [];
2792
+ }
2793
+ var out = [];
2794
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2795
+ try {
2796
+ for(var _iterator = set2[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2797
+ var targetSymbol = _step.value;
2798
+ var target = this.entries.get(targetSymbol);
2799
+ if (target) {
2800
+ out.push(target.key);
2801
+ }
2802
+ }
2803
+ } catch (err) {
2804
+ _didIteratorError = true;
2805
+ _iteratorError = err;
2806
+ } finally{
2807
+ try {
2808
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2809
+ _iterator.return();
2810
+ }
2811
+ } finally{
2812
+ if (_didIteratorError) {
2813
+ throw _iteratorError;
2814
+ }
2815
+ }
2816
+ }
2817
+ return out;
2818
+ }
2819
+ },
2820
+ {
2821
+ /**
2822
+ * Return every key transitively downstream of [sourceSymbol] — direct
2823
+ * dependents, their dependents, and so on. Ordered breadth-first so nearer
2824
+ * dependents come first, deduped so a key reachable by several paths (a
2825
+ * diamond) appears once, and cycle-safe.
2826
+ *
2827
+ * The source itself is never included — `set()` notifies it directly, so
2828
+ * re-emitting it here would double-notify subscribers on a cyclic graph.
2829
+ */ key: "transitiveDependentsOf",
2830
+ value: function transitiveDependentsOf(sourceSymbol) {
2831
+ var visited = /* @__PURE__ */ new Set([
2832
+ sourceSymbol
2833
+ ]);
2834
+ var out = [];
2835
+ var queue = [
2836
+ sourceSymbol
2837
+ ];
2838
+ while(queue.length > 0){
2839
+ var current2 = queue.shift();
2840
+ var set2 = this.dependents.get(current2);
2841
+ if (!set2) continue;
2842
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2843
+ try {
2844
+ for(var _iterator = set2[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2845
+ var targetSymbol = _step.value;
2846
+ if (visited.has(targetSymbol)) continue;
2847
+ visited.add(targetSymbol);
2848
+ var target = this.entries.get(targetSymbol);
2849
+ if (target) {
2850
+ out.push(target.key);
2851
+ }
2852
+ queue.push(targetSymbol);
2853
+ }
2854
+ } catch (err) {
2855
+ _didIteratorError = true;
2856
+ _iteratorError = err;
2857
+ } finally{
2858
+ try {
2859
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2860
+ _iterator.return();
2861
+ }
2862
+ } finally{
2863
+ if (_didIteratorError) {
2864
+ throw _iteratorError;
2865
+ }
2866
+ }
2867
+ }
2868
+ }
2869
+ return out;
2870
+ }
2871
+ },
2872
+ {
2873
+ key: "list",
2874
+ value: function list() {
2875
+ var out = [];
2876
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2877
+ try {
2878
+ for(var _iterator = this.entries.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2879
+ var entry = _step.value;
2880
+ out.push({
2881
+ symbol: entry.key.symbol,
2882
+ description: entry.key.description,
2883
+ hasValue: entry.hasLiteral,
2884
+ hasTransform: Boolean(entry.transform)
2885
+ });
2886
+ }
2887
+ } catch (err) {
2888
+ _didIteratorError = true;
2889
+ _iteratorError = err;
2890
+ } finally{
2891
+ try {
2892
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2893
+ _iterator.return();
2894
+ }
2895
+ } finally{
2896
+ if (_didIteratorError) {
2897
+ throw _iteratorError;
2898
+ }
2899
+ }
2900
+ }
2901
+ return out;
2902
+ }
2903
+ },
2904
+ {
2905
+ key: "freeze",
2906
+ value: function freeze(meta) {
2907
+ var frozenEntries = [];
2908
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2909
+ try {
2910
+ for(var _iterator = this.entries.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2911
+ var entry = _step.value;
2912
+ if (!entry.hasLiteral && !entry.transform) {
2913
+ continue;
2914
+ }
2915
+ var computed = this.compute(entry.key.symbol);
2916
+ var value = tombstoneFunctions(computed, entry.key.description);
2917
+ frozenEntries.push(deepFreezeEntry({
2918
+ symbol: entry.key.symbol,
2919
+ name: nameOfContextKey(entry.key),
2920
+ description: entry.key.description,
2921
+ value: value
2922
+ }));
2923
+ }
2924
+ } catch (err) {
2925
+ _didIteratorError = true;
2926
+ _iteratorError = err;
2927
+ } finally{
2928
+ try {
2929
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2930
+ _iterator.return();
2931
+ }
2932
+ } finally{
2933
+ if (_didIteratorError) {
2934
+ throw _iteratorError;
2935
+ }
2936
+ }
2937
+ }
2938
+ var bySymbol = new Map(frozenEntries.map(function(e) {
2939
+ return [
2940
+ e.symbol,
2941
+ e.value
2942
+ ];
2943
+ }));
2944
+ var snapshot = {
2945
+ flowId: meta.flowId,
2946
+ endedAt: meta.endedAt,
2947
+ entries: Object.freeze(frozenEntries),
2948
+ get: function get(key) {
2949
+ return bySymbol.get(key.symbol);
2950
+ }
2951
+ };
2952
+ return Object.freeze(snapshot);
2953
+ }
2954
+ },
2955
+ {
2956
+ key: "compute",
2957
+ value: function compute(sym) {
2958
+ var _this = this;
2959
+ var entry = this.entries.get(sym);
2960
+ if (!entry) return void 0;
2961
+ if (entry.hasLiteral) return entry.literal;
2962
+ if (!entry.transform) return void 0;
2963
+ var reader = function(otherKey) {
2964
+ return _this.compute(otherKey.symbol);
2965
+ };
2966
+ return entry.transform.compute(reader);
2967
+ }
2968
+ }
2969
+ ]);
2970
+ return ContextStore;
2971
+ }();
2972
+ var ContextHistory = /*#__PURE__*/ function() {
2973
+ function ContextHistory() {
2974
+ _class_call_check(this, ContextHistory);
2975
+ this.stack = [];
2976
+ }
2977
+ _create_class(ContextHistory, [
2978
+ {
2979
+ key: "push",
2980
+ value: function push(snapshot) {
2981
+ this.stack.push(snapshot);
2982
+ }
2983
+ },
2984
+ {
2985
+ key: "entries",
2986
+ value: function entries() {
2987
+ return this.stack;
2988
+ }
2989
+ },
2990
+ {
2991
+ key: "size",
2992
+ value: function size() {
2993
+ return this.stack.length;
2994
+ }
2995
+ },
2996
+ {
2997
+ key: "clear",
2998
+ value: function clear() {
2999
+ this.stack = [];
3000
+ }
3001
+ }
3002
+ ]);
3003
+ return ContextHistory;
3004
+ }();
3005
+ var ContextPluginSymbol = Symbol.for("ContextPlugin");
3006
+ var subscriptionCounter = 0;
3007
+ var _ContextPlugin = /*#__PURE__*/ function() {
3008
+ function _ContextPlugin2() {
3009
+ _class_call_check(this, _ContextPlugin2);
3010
+ this.name = "context";
3011
+ this.symbol = _ContextPlugin2.Symbol;
3012
+ this.hooks = {
3013
+ onSet: new SyncHook(),
3014
+ resolveValue: new SyncWaterfallHook(),
3015
+ onRegister: new SyncHook(),
3016
+ onFlowFrozen: new SyncHook()
3017
+ };
3018
+ this.transforms = /* @__PURE__ */ new Map();
3019
+ this.perKeySubs = /* @__PURE__ */ new Map();
3020
+ this.globalSubs = /* @__PURE__ */ new Map();
3021
+ this.tokenIndex = /* @__PURE__ */ new Map();
3022
+ this.lastNotified = /* @__PURE__ */ new Map();
3023
+ this.store = new ContextStore();
3024
+ this.historyStack = new ContextHistory();
3025
+ }
3026
+ _create_class(_ContextPlugin2, [
3027
+ {
3028
+ key: "apply",
3029
+ value: function apply(player) {
3030
+ var _this = this;
3031
+ var existing = player.findPlugin(ContextPluginSymbol);
3032
+ if (existing !== void 0 && existing !== this) {
3033
+ this.store = existing.store;
3034
+ this.historyStack = existing.historyStack;
3035
+ this.transforms = existing.transforms;
3036
+ this.perKeySubs = existing.perKeySubs;
3037
+ this.globalSubs = existing.globalSubs;
3038
+ this.tokenIndex = existing.tokenIndex;
3039
+ this.lastNotified = existing.lastNotified;
3040
+ return;
3041
+ }
3042
+ player.hooks.onStart.tap(this.name, function(flow) {
3043
+ var _flow;
3044
+ _this.currentFlowId = (_flow = flow) === null || _flow === void 0 ? void 0 : _flow.id;
3045
+ });
3046
+ player.hooks.onEnd.tap(this.name, function() {
3047
+ var snapshot = _this.store.freeze({
3048
+ flowId: _this.currentFlowId,
3049
+ endedAt: Date.now()
3050
+ });
3051
+ _this.historyStack.push(snapshot);
3052
+ _this.hooks.onFlowFrozen.call(snapshot);
3053
+ _this.rotateStore();
3054
+ _this.currentFlowId = void 0;
3055
+ });
3056
+ }
3057
+ },
3058
+ {
3059
+ key: "register",
3060
+ value: function register(key) {
3061
+ var added = this.store.register(key);
3062
+ if (added) {
3063
+ this.hooks.onRegister.call(key);
3064
+ }
3065
+ }
3066
+ },
3067
+ {
3068
+ key: "set",
3069
+ value: function set(key, value) {
3070
+ var isFirstSighting = !this.store.has(key);
3071
+ this.store.set(key, value);
3072
+ if (isFirstSighting) {
3073
+ this.hooks.onRegister.call(key);
3074
+ }
3075
+ this.notifyIfChanged(key, value);
3076
+ }
3077
+ },
3078
+ {
3079
+ key: "get",
3080
+ value: function get(key) {
3081
+ var raw = this.store.get(key);
3082
+ var resolved = this.hooks.resolveValue.call(raw, key);
3083
+ return resolved;
3084
+ }
3085
+ },
3086
+ {
3087
+ key: "has",
3088
+ value: function has(key) {
3089
+ return this.store.has(key);
3090
+ }
3091
+ },
3092
+ {
3093
+ key: "registerTransform",
3094
+ value: function registerTransform(key, transform) {
3095
+ var isFirstSighting = !this.store.has(key);
3096
+ this.store.registerTransform(key, transform);
3097
+ this.transforms.set(key.symbol, {
3098
+ key: key,
3099
+ transform: {
3100
+ sources: transform.sources,
3101
+ compute: transform.compute
3102
+ }
3103
+ });
3104
+ if (isFirstSighting) {
3105
+ this.hooks.onRegister.call(key);
3106
+ }
3107
+ }
3108
+ },
3109
+ {
3110
+ key: "subscribe",
3111
+ value: function subscribe(key, handler) {
3112
+ var token = this.nextToken();
3113
+ var bucket = this.perKeySubs.get(key.symbol);
3114
+ if (!bucket) {
3115
+ bucket = /* @__PURE__ */ new Map();
3116
+ this.perKeySubs.set(key.symbol, bucket);
3117
+ }
3118
+ bucket.set(token, handler);
3119
+ this.tokenIndex.set(token, key.symbol);
3120
+ return token;
3121
+ }
3122
+ },
3123
+ {
3124
+ key: "subscribeAll",
3125
+ value: function subscribeAll(handler) {
3126
+ var token = this.nextToken();
3127
+ this.globalSubs.set(token, handler);
3128
+ this.tokenIndex.set(token, void 0);
3129
+ return token;
3130
+ }
3131
+ },
3132
+ {
3133
+ key: "unsubscribe",
3134
+ value: function unsubscribe(token) {
3135
+ var owner = this.tokenIndex.get(token);
3136
+ if (owner === void 0) {
3137
+ this.globalSubs.delete(token);
3138
+ } else {
3139
+ var _this_perKeySubs_get;
3140
+ (_this_perKeySubs_get = this.perKeySubs.get(owner)) === null || _this_perKeySubs_get === void 0 ? void 0 : _this_perKeySubs_get.delete(token);
3141
+ }
3142
+ this.tokenIndex.delete(token);
3143
+ }
3144
+ },
3145
+ {
3146
+ key: "list",
3147
+ value: function list() {
3148
+ return this.store.list();
3149
+ }
3150
+ },
3151
+ {
3152
+ key: "history",
3153
+ value: function history() {
3154
+ return this.historyStack.entries();
3155
+ }
3156
+ },
3157
+ {
3158
+ key: "snapshot",
3159
+ value: function snapshot() {
3160
+ return this.store.freeze({
3161
+ flowId: this.currentFlowId,
3162
+ endedAt: Date.now()
3163
+ });
3164
+ }
3165
+ },
3166
+ {
3167
+ /**
3168
+ * Bridge-friendly: set a value by string name. Used by native wrappers that
3169
+ * cannot construct a `ContextKey` object directly.
3170
+ */ key: "setByName",
3171
+ value: function setByName(name, description, value) {
3172
+ this.set(this.ensureNamedKey(name, description), value);
3173
+ }
3174
+ },
3175
+ {
3176
+ /** Bridge-friendly: get a value by string name. */ key: "getByName",
3177
+ value: function getByName(name) {
3178
+ return this.get(this.ensureNamedKey(name));
3179
+ }
3180
+ },
3181
+ {
3182
+ /** Bridge-friendly: check presence by string name. */ key: "hasByName",
3183
+ value: function hasByName(name) {
3184
+ return this.has(this.ensureNamedKey(name));
3185
+ }
3186
+ },
3187
+ {
3188
+ /** Bridge-friendly: subscribe by string name. */ key: "subscribeByName",
3189
+ value: function subscribeByName(name, description, handler) {
3190
+ return this.subscribe(this.ensureNamedKey(name, description), function(value) {
3191
+ return handler(value, name);
3192
+ });
3193
+ }
3194
+ },
3195
+ {
3196
+ /**
3197
+ * Bridge-friendly: subscribe to all updates. The handler receives the
3198
+ * key's resolved name (or undefined for non-namespaced keys).
3199
+ */ key: "subscribeAllByName",
3200
+ value: function subscribeAllByName(handler) {
3201
+ return this.subscribeAll(function(value, key) {
3202
+ return handler(value, nameOfContextKey(key), key.description);
3203
+ });
3204
+ }
3205
+ },
3206
+ {
3207
+ key: "ensureNamedKey",
3208
+ value: function ensureNamedKey(name, description) {
3209
+ return defineContextKey(name, description !== null && description !== void 0 ? description : name);
3210
+ }
3211
+ },
3212
+ {
3213
+ /**
3214
+ * Notify subscribers of `key` with `value`, unless it's `Object.is`-equal
3215
+ * to the value the last notification for this key carried. Then cascade to
3216
+ * every transitive dependent (a chained transform root -> mid -> top must
3217
+ * notify `top` when `root` changes, not just the directly-dependent `mid`),
3218
+ * applying the same unchanged-value guard to each. `transitiveDependentsOf`
3219
+ * already flattens the full downstream closure in one deduped, cycle-safe
3220
+ * pass, so this walks it directly rather than recursing back through this
3221
+ * method (which would re-walk the graph from each dependent and, on a
3222
+ * diamond, notify a shared descendant more than once).
3223
+ */ key: "notifyIfChanged",
3224
+ value: function notifyIfChanged(key, value) {
3225
+ this.publishIfChanged(key, value);
3226
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3227
+ try {
3228
+ for(var _iterator = this.store.transitiveDependentsOf(key.symbol)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3229
+ var dep = _step.value;
3230
+ this.publishIfChanged(dep, this.store.get(dep));
3231
+ }
3232
+ } catch (err) {
3233
+ _didIteratorError = true;
3234
+ _iteratorError = err;
3235
+ } finally{
3236
+ try {
3237
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3238
+ _iterator.return();
3239
+ }
3240
+ } finally{
3241
+ if (_didIteratorError) {
3242
+ throw _iteratorError;
3243
+ }
3244
+ }
3245
+ }
3246
+ }
3247
+ },
3248
+ {
3249
+ key: "publishIfChanged",
3250
+ value: function publishIfChanged(key, value) {
3251
+ var hasNotified = this.lastNotified.has(key.symbol);
3252
+ var unchanged = hasNotified && Object.is(this.lastNotified.get(key.symbol), value);
3253
+ this.lastNotified.set(key.symbol, value);
3254
+ if (!unchanged) {
3255
+ this.notify(key, value);
3256
+ }
3257
+ }
3258
+ },
3259
+ {
3260
+ key: "notify",
3261
+ value: function notify(key, value) {
3262
+ this.hooks.onSet.call(key, value);
3263
+ var bucket = this.perKeySubs.get(key.symbol);
3264
+ if (bucket) {
3265
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3266
+ try {
3267
+ for(var _iterator = bucket.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3268
+ var handler = _step.value;
3269
+ handler(value, key);
3270
+ }
3271
+ } catch (err) {
3272
+ _didIteratorError = true;
3273
+ _iteratorError = err;
3274
+ } finally{
3275
+ try {
3276
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3277
+ _iterator.return();
3278
+ }
3279
+ } finally{
3280
+ if (_didIteratorError) {
3281
+ throw _iteratorError;
3282
+ }
3283
+ }
3284
+ }
3285
+ }
3286
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
3287
+ try {
3288
+ for(var _iterator1 = this.globalSubs.values()[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
3289
+ var handler1 = _step1.value;
3290
+ handler1(value, key);
3291
+ }
3292
+ } catch (err) {
3293
+ _didIteratorError1 = true;
3294
+ _iteratorError1 = err;
3295
+ } finally{
3296
+ try {
3297
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
3298
+ _iterator1.return();
3299
+ }
3300
+ } finally{
3301
+ if (_didIteratorError1) {
3302
+ throw _iteratorError1;
3303
+ }
3304
+ }
3305
+ }
3306
+ }
3307
+ },
3308
+ {
3309
+ key: "rotateStore",
3310
+ value: function rotateStore() {
3311
+ this.store = new ContextStore();
3312
+ this.lastNotified.clear();
3313
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3314
+ try {
3315
+ for(var _iterator = this.transforms.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3316
+ var _step_value = _step.value, key = _step_value.key, transform = _step_value.transform;
3317
+ this.store.registerTransform(key, transform);
3318
+ }
3319
+ } catch (err) {
3320
+ _didIteratorError = true;
3321
+ _iteratorError = err;
3322
+ } finally{
3323
+ try {
3324
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3325
+ _iterator.return();
3326
+ }
3327
+ } finally{
3328
+ if (_didIteratorError) {
3329
+ throw _iteratorError;
3330
+ }
3331
+ }
3332
+ }
3333
+ }
3334
+ },
3335
+ {
3336
+ key: "nextToken",
3337
+ value: function nextToken() {
3338
+ subscriptionCounter += 1;
3339
+ return "ctx_".concat(subscriptionCounter);
3340
+ }
3341
+ }
3342
+ ]);
3343
+ return _ContextPlugin2;
3344
+ }();
3345
+ _ContextPlugin.Symbol = ContextPluginSymbol;
3346
+ var ContextPlugin = _ContextPlugin;
3347
+ var flowIdContextKey = defineContextKey("player.flow.id", "Identifier of the running flow");
3348
+ var flowStateContextKey = defineContextKey("player.flow.state", "Name of the current FSM state in the running flow");
3349
+ var viewIdContextKey = defineContextKey("player.view.id", "Identifier of the currently-resolved view");
3350
+ var viewContextKey = defineContextKey("player.view", "Full resolved view object for the current FSM state");
3351
+ var dataContextKey = defineContextKey("player.data", "Full data model tree for the running flow");
3352
+ var playerStatusContextKey = defineContextKey("player.status", "Player flow status: not-started, in-progress, completed, or error");
3353
+ var validationContextKey = defineContextKey("player.validation", "Validation state for the running view, keyed by binding");
3354
+ var setDataActionKey = defineContextKey("player.data.set", "Set a value in the Player data model at the given binding");
3355
+ var transitionActionKey = defineContextKey("player.flow.transition", "Transition the current flow using the given transition value");
3356
+ var playerStateContextKey = defineContextKey("player.state", "Aggregated snapshot of every Player runtime context entry");
3357
+ var StateContextPlugin = /*#__PURE__*/ function() {
3358
+ function StateContextPlugin() {
3359
+ _class_call_check(this, StateContextPlugin);
3360
+ this.name = "state-context";
3361
+ }
3362
+ _create_class(StateContextPlugin, [
3363
+ {
3364
+ key: "apply",
3365
+ value: function apply(player) {
3366
+ var _this = this;
3367
+ var ctx = getContextPlugin(player);
3368
+ var validationController;
3369
+ var publishValidation = function() {
3370
+ if (!validationController) return;
3371
+ var byBinding = {};
3372
+ var canTransition = true;
3373
+ validationController.getBindings().forEach(function(binding) {
3374
+ var _validationController_getValidationForBinding;
3375
+ var _validationController_getValidationForBinding_getAll;
3376
+ var all = (_validationController_getValidationForBinding_getAll = (_validationController_getValidationForBinding = validationController.getValidationForBinding(binding)) === null || _validationController_getValidationForBinding === void 0 ? void 0 : _validationController_getValidationForBinding.getAll()) !== null && _validationController_getValidationForBinding_getAll !== void 0 ? _validationController_getValidationForBinding_getAll : [];
3377
+ if (all.length === 0) return;
3378
+ byBinding[binding.asString()] = all.map(function(v) {
3379
+ return {
3380
+ severity: v.severity,
3381
+ message: v.message,
3382
+ displayTarget: v.displayTarget,
3383
+ blocking: v.blocking
3384
+ };
3385
+ });
3386
+ if (all.some(function(v) {
3387
+ return v.blocking;
3388
+ })) {
3389
+ canTransition = false;
3390
+ }
3391
+ });
3392
+ ctx.set(validationContextKey, {
3393
+ canTransition: canTransition,
3394
+ byBinding: byBinding
3395
+ });
3396
+ };
3397
+ ctx.register(flowIdContextKey);
3398
+ ctx.register(flowStateContextKey);
3399
+ ctx.register(viewIdContextKey);
3400
+ ctx.register(viewContextKey);
3401
+ ctx.register(dataContextKey);
3402
+ ctx.register(playerStatusContextKey);
3403
+ ctx.register(validationContextKey);
3404
+ ctx.register(setDataActionKey);
3405
+ ctx.register(transitionActionKey);
3406
+ ctx.set(playerStatusContextKey, player.getState().status);
3407
+ ctx.registerTransform(playerStateContextKey, {
3408
+ sources: [
3409
+ flowIdContextKey,
3410
+ flowStateContextKey,
3411
+ viewIdContextKey,
3412
+ viewContextKey,
3413
+ dataContextKey,
3414
+ playerStatusContextKey,
3415
+ validationContextKey,
3416
+ setDataActionKey,
3417
+ transitionActionKey
3418
+ ],
3419
+ compute: function(read) {
3420
+ var flowId = read(flowIdContextKey);
3421
+ var flowState = read(flowStateContextKey);
3422
+ var transition = read(transitionActionKey);
3423
+ var viewId = read(viewIdContextKey);
3424
+ var viewResolved = read(viewContextKey);
3425
+ var dataModel = read(dataContextKey);
3426
+ var setData = read(setDataActionKey);
3427
+ var _read;
3428
+ return {
3429
+ // Always present — seeded eagerly above and kept live by the
3430
+ // `player.hooks.state` tap below.
3431
+ status: (_read = read(playerStatusContextKey)) !== null && _read !== void 0 ? _read : "not-started",
3432
+ flow: flowId !== void 0 || flowState !== void 0 || transition !== void 0 ? {
3433
+ id: flowId,
3434
+ state: flowState,
3435
+ transition: transition
3436
+ } : void 0,
3437
+ view: viewId !== void 0 || viewResolved !== void 0 ? {
3438
+ id: viewId,
3439
+ resolved: viewResolved
3440
+ } : void 0,
3441
+ data: dataModel !== void 0 || setData !== void 0 ? {
3442
+ model: dataModel,
3443
+ set: setData
3444
+ } : void 0,
3445
+ validation: read(validationContextKey)
3446
+ };
3447
+ }
3448
+ });
3449
+ player.hooks.onStart.tap(this.name, function(flow) {
3450
+ var _flow;
3451
+ if ((_flow = flow) === null || _flow === void 0 ? void 0 : _flow.id) {
3452
+ ctx.set(flowIdContextKey, flow.id);
3453
+ }
3454
+ });
3455
+ player.hooks.state.tap(this.name, function(state) {
3456
+ ctx.set(playerStatusContextKey, state.status);
3457
+ });
3458
+ player.hooks.flowController.tap(this.name, function(flowController) {
3459
+ var transition = function(value) {
3460
+ return flowController.transition(value);
3461
+ };
3462
+ ctx.set(transitionActionKey, transition);
3463
+ flowController.hooks.flow.tap(_this.name, function(flowInstance) {
3464
+ var recordState = function() {
3465
+ var _flowInstance_currentState;
3466
+ var name = (_flowInstance_currentState = flowInstance.currentState) === null || _flowInstance_currentState === void 0 ? void 0 : _flowInstance_currentState.name;
3467
+ if (name) {
3468
+ ctx.set(flowStateContextKey, name);
3469
+ }
3470
+ };
3471
+ recordState();
3472
+ flowInstance.hooks.afterTransition.tap(_this.name, recordState);
3473
+ });
3474
+ });
3475
+ player.hooks.validationController.tap(this.name, function(vc) {
3476
+ validationController = vc;
3477
+ publishValidation();
3478
+ });
3479
+ player.hooks.viewController.tap(this.name, function(viewController) {
3480
+ viewController.hooks.view.tap(_this.name, function(view) {
3481
+ var _view_initialView;
3482
+ var id = (_view_initialView = view.initialView) === null || _view_initialView === void 0 ? void 0 : _view_initialView.id;
3483
+ if (id) {
3484
+ ctx.set(viewIdContextKey, id);
3485
+ }
3486
+ view.hooks.onUpdate.tap(_this.name, function(resolved) {
3487
+ var _resolved;
3488
+ ctx.set(viewContextKey, resolved);
3489
+ if ((_resolved = resolved) === null || _resolved === void 0 ? void 0 : _resolved.id) {
3490
+ ctx.set(viewIdContextKey, resolved.id);
3491
+ }
3492
+ publishValidation();
3493
+ });
3494
+ });
3495
+ });
3496
+ player.hooks.dataController.tap(this.name, function(dataController) {
3497
+ var setData = function(binding, value) {
3498
+ dataController.set([
3499
+ [
3500
+ binding,
3501
+ value
3502
+ ]
3503
+ ]);
3504
+ };
3505
+ ctx.set(setDataActionKey, setData);
3506
+ var publish = function() {
3507
+ ctx.set(dataContextKey, dataController.serialize());
3508
+ publishValidation();
3509
+ };
3510
+ dataController.hooks.onUpdate.tap(_this.name, publish);
3511
+ publish();
3512
+ });
3513
+ }
3514
+ }
3515
+ ]);
3516
+ return StateContextPlugin;
3517
+ }();
3518
+ // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/basic/core/src/context.ts
3519
+ var playerConfigContextKey = defineContextKey("devtools.player.config", "Player version and the names of its registered plugins");
2322
3520
  // ../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/devtools/plugins/basic/core/src/plugin.ts
2323
3521
  var BasicDevtoolsPlugin = /*#__PURE__*/ function(DevtoolsPlugin) {
2324
3522
  _inherits(BasicDevtoolsPlugin, DevtoolsPlugin);
@@ -2333,6 +3531,7 @@ var BasicDevtoolsPlugin = function() {
2333
3531
  _this.data = {};
2334
3532
  _this.playerConfig = {};
2335
3533
  _this.logs = [];
3534
+ /** Subscriptions are tied to the context plugin they were made on, which differs per Player */ _this.subscriptions = [];
2336
3535
  return _this;
2337
3536
  }
2338
3537
  _create_class(BasicDevtoolsPlugin, [
@@ -2343,30 +3542,48 @@ var BasicDevtoolsPlugin = function() {
2343
3542
  this.logger = new WeakRef(player.logger);
2344
3543
  if (!this.checkIfDevtoolsIsActive()) return;
2345
3544
  _get(_get_prototype_of(BasicDevtoolsPlugin.prototype), "apply", this).call(this, player);
2346
- this.playerConfig = {
2347
- version: player.getVersion(),
2348
- plugins: player.getPlugins().map(function(plugin) {
2349
- return plugin.name;
2350
- })
2351
- };
2352
- this.dispatchDataUpdate({
2353
- playerConfig: this.playerConfig
3545
+ var context = getContextPlugin(player);
3546
+ if (!player.getPlugins().some(function(p) {
3547
+ return p.name === "state-context";
3548
+ })) {
3549
+ player.registerPlugin(new StateContextPlugin());
3550
+ }
3551
+ this.subscriptions.forEach(function(param) {
3552
+ var previous = param.context, token = param.token;
3553
+ return previous.unsubscribe(token);
2354
3554
  });
2355
- player.hooks.dataController.tap(this.name, function(dataController) {
2356
- dataController.hooks.onUpdate.tap(_this.name, function(updates) {
2357
- _this.data = produce(_this.data, function(draft) {
2358
- updates.forEach(function(param) {
2359
- var binding = param.binding, newValue = param.newValue;
2360
- dsetAssign(draft, [
2361
- "data"
2362
- ].concat(_to_consumable_array(binding.asArray())), newValue);
3555
+ this.subscriptions = [
3556
+ {
3557
+ context: context,
3558
+ token: context.subscribe(playerConfigContextKey, function(playerConfig) {
3559
+ if (!playerConfig) return;
3560
+ _this.playerConfig = _object_spread({}, playerConfig);
3561
+ _this.dispatchDataUpdate({
3562
+ playerConfig: _this.playerConfig
2363
3563
  });
2364
- });
2365
- _this.dispatchDataUpdate({
2366
- data: _this.data
2367
- });
3564
+ })
3565
+ },
3566
+ {
3567
+ context: context,
3568
+ token: context.subscribe(dataContextKey, function(model) {
3569
+ _this.data = {
3570
+ data: model === void 0 ? model : JSON.parse(JSON.stringify(model))
3571
+ };
3572
+ _this.dispatchDataUpdate({
3573
+ data: _this.data
3574
+ });
3575
+ })
3576
+ }
3577
+ ];
3578
+ var publishConfig = function() {
3579
+ return context.set(playerConfigContextKey, {
3580
+ version: player.getVersion(),
3581
+ plugins: player.getPlugins().map(function(plugin) {
3582
+ return plugin.name;
3583
+ })
2368
3584
  });
2369
- });
3585
+ };
3586
+ publishConfig();
2370
3587
  player.logger.hooks.log.tap(this.name, function(severity, message) {
2371
3588
  _this.logs = _to_consumable_array(_this.logs).concat([
2372
3589
  {
@@ -2384,9 +3601,7 @@ var BasicDevtoolsPlugin = function() {
2384
3601
  flow: _this.flow
2385
3602
  });
2386
3603
  });
2387
- player.hooks.view.tap(this.name, function(view) {
2388
- _this.view = new WeakRef(view);
2389
- });
3604
+ player.hooks.onStart.tap(this.name, publishConfig);
2390
3605
  player.hooks.expressionEvaluator.tap(this.name, function(evaluator) {
2391
3606
  _this.expressionEvaluator = new WeakRef(evaluator);
2392
3607
  });